-
Notifications
You must be signed in to change notification settings - Fork 0
Add table command
#2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
abennett
wants to merge
3
commits into
main
Choose a base branch
from
table
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| # CLAUDE.md | ||
|
|
||
| This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. | ||
|
|
||
| ## Build & Run | ||
|
|
||
| ```bash | ||
| go build -o ruok . # build binary | ||
| go run . # run without building | ||
| go test ./... # run tests | ||
| go vet ./... # lint | ||
| ``` | ||
|
|
||
| ## Architecture | ||
|
|
||
| Single-package (`main`) Go CLI that queries [Atlassian Statuspage](https://www.atlassian.com/software/statuspage) APIs to show service health from the terminal. Uses `urfave/cli/v3` for command routing. | ||
|
|
||
| **Key files:** | ||
|
|
||
| - `main.go` — entrypoint, builds and runs the root command | ||
| - `cli.go` — CLI command definitions and action handlers (`check`, `list`, `add`, `table`) | ||
| - `tui.go` — Bubbletea-based interactive dashboard (`table` command); fetches all services concurrently, renders a `bubbles/table` sorted by severity, supports drill-down detail view | ||
| - `statuspage.go` — `StatusPage` type with API calls (`/api/v2/components.json`, `/api/v2/incidents/unresolved.json`), response types (`Component`, `Incident`, etc.), config loading/saving (YAML at `~/.config/ruok/config.yaml`), and service resolution logic | ||
| - `status.go` — `Status` enum type (operational → critical) with JSON unmarshaling, emoji `String()`, and severity ordering | ||
| - `impact.go` — `Impact` enum type (operational → critical) with JSON unmarshaling and emoji `String()` | ||
| - `registry.go` — built-in service name→URL map (github, cloudflare, datadog, etc.) | ||
|
|
||
| **Dependencies:** `urfave/cli/v3` for command routing; `charmbracelet/bubbletea`, `charmbracelet/bubbles`, `charmbracelet/lipgloss` for the interactive TUI. | ||
|
|
||
| **Service resolution order** (in `resolveStatusPage`): CLI arg → config `default` → falls back to GitHub. Arguments can be a registry name (case-insensitive) or a raw URL. | ||
|
|
||
| **Config** (`~/.config/ruok/config.yaml`): `pages` map merges into the built-in registry (user entries override); `default` sets the service used when no arg is given. `ruok add` validates and writes to this file. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "strings" | ||
| ) | ||
|
|
||
| type Impact int | ||
|
|
||
| const ( | ||
| ImpactOperational Impact = iota | ||
| ImpactMinor | ||
| ImpactMajor | ||
| ImpactCritical | ||
| ImpactUnknown | ||
| ) | ||
|
|
||
| func (i *Impact) UnmarshalJSON(data []byte) error { | ||
| impact := strings.ToLower(string(data)) | ||
| impact = strings.Trim(impact, `"`) | ||
| switch impact { | ||
| case "operational": | ||
| *i = ImpactOperational | ||
| case "minor": | ||
| *i = ImpactMinor | ||
| case "major": | ||
| *i = ImpactMajor | ||
| case "critical": | ||
| *i = ImpactCritical | ||
| default: | ||
| *i = ImpactUnknown | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| func (i Impact) String() string { | ||
| switch i { | ||
| case ImpactOperational: | ||
| return "✅" | ||
| case ImpactMinor: | ||
| return "🟡" | ||
| case ImpactMajor: | ||
| return "🟠" | ||
| case ImpactCritical: | ||
| return "🔴" | ||
| default: | ||
| return "❔" | ||
| } | ||
| } | ||
|
|
||
| func (i Impact) Name() string { | ||
| switch i { | ||
| case ImpactOperational: | ||
| return "operational" | ||
| case ImpactMinor: | ||
| return "minor" | ||
| case ImpactMajor: | ||
| return "major" | ||
| case ImpactCritical: | ||
| return "critical" | ||
| default: | ||
| return "unknown" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "encoding/json" | ||
| "testing" | ||
| ) | ||
|
|
||
| func TestImpactUnmarshalJSON(t *testing.T) { | ||
| tests := []struct { | ||
| input string | ||
| want Impact | ||
| }{ | ||
| {`"operational"`, ImpactOperational}, | ||
| {`"minor"`, ImpactMinor}, | ||
| {`"major"`, ImpactMajor}, | ||
| {`"critical"`, ImpactCritical}, | ||
| {`"MINOR"`, ImpactMinor}, | ||
| {`"Critical"`, ImpactCritical}, | ||
| {`"something_else"`, ImpactUnknown}, | ||
| } | ||
| for _, tt := range tests { | ||
| t.Run(tt.input, func(t *testing.T) { | ||
| var i Impact | ||
| if err := json.Unmarshal([]byte(tt.input), &i); err != nil { | ||
| t.Fatalf("Unmarshal(%s): %v", tt.input, err) | ||
| } | ||
| if i != tt.want { | ||
| t.Errorf("Unmarshal(%s) = %d, want %d", tt.input, i, tt.want) | ||
| } | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| func TestImpactString(t *testing.T) { | ||
| tests := []struct { | ||
| i Impact | ||
| want string | ||
| }{ | ||
| {ImpactOperational, "✅"}, | ||
| {ImpactMinor, "🟡"}, | ||
| {ImpactMajor, "🟠"}, | ||
| {ImpactCritical, "🔴"}, | ||
| {ImpactUnknown, "❔"}, | ||
| } | ||
| for _, tt := range tests { | ||
| got := tt.i.String() | ||
| if got != tt.want { | ||
| t.Errorf("Impact(%d).String() = %q, want %q", tt.i, got, tt.want) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| func TestImpactName(t *testing.T) { | ||
| tests := []struct { | ||
| i Impact | ||
| want string | ||
| }{ | ||
| {ImpactOperational, "operational"}, | ||
| {ImpactMinor, "minor"}, | ||
| {ImpactMajor, "major"}, | ||
| {ImpactCritical, "critical"}, | ||
| {ImpactUnknown, "unknown"}, | ||
| } | ||
| for _, tt := range tests { | ||
| got := tt.i.Name() | ||
| if got != tt.want { | ||
| t.Errorf("Impact(%d).Name() = %q, want %q", tt.i, got, tt.want) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| func TestImpactSeverityOrdering(t *testing.T) { | ||
| ordered := []Impact{ | ||
| ImpactOperational, | ||
| ImpactMinor, | ||
| ImpactMajor, | ||
| ImpactCritical, | ||
| ImpactUnknown, | ||
| } | ||
| for i := 1; i < len(ordered); i++ { | ||
| if ordered[i] <= ordered[i-1] { | ||
| t.Errorf("expected %d > %d in severity ordering", ordered[i], ordered[i-1]) | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.