How applejag/kubectl-klock works
kubectl-klock is a terminal UI for streaming Kubernetes resource-watch results in a kubectl-get-like table. The workflow starts with a kubectl user invoking the Cobra command, which resolves options and hands resource arguments to the watch-and-print runtime; updates populate the interactive table. The README also documents filtering, pagination, deleted-row handling, color themes, and kubeconfig-triggered watch restarts. Relationships below use shown imports/calls or README statements; some runtime details are unsampled, so uncertain links are omitted.
Main entry points: klock.go Watch runtime · table.go Terminal table UI · root.go CLI command · optionalduration.go Optional duration
Components 16
Command entry
- Program entry
main.go - CLI command
cmd/root.go - Shell completion
cmd/completion.go
Watch and render
- Watch runtime
pkg/klock/klock.go - Watch decoding
pkg/klock/decoder.go - Resource printer
pkg/klock/klock.go - Output formatting
pkg/klock/parsing.go - Status coloring
pkg/klock/color.go
Interactive table
- Terminal table UI
pkg/table/table.go - Key bindings
pkg/table/keys.go - Row model
pkg/table/row.go
Shared behavior
- Optional duration
pkg/types/optionalduration.go - Duration parsing
internal/util/humanduration.go - String splitting
internal/util/strings.go
Other components
- kubectl user
- Kubernetes API
Connections 18
- kubectl user → Program entry: invokes
README.md - Program entry → CLI command: starts
main.go - CLI command → Watch runtime: executes
cmd/root.go - CLI command → Shell completion: registers
cmd/root.go - CLI command → Optional duration: configures
cmd/root.go - Watch runtime → Kubernetes API: watches
README.md - Watch runtime → Terminal table UI: updates
pkg/klock/klock.go - Watch runtime → Resource printer: configures
pkg/klock/klock.go - Resource printer → Terminal table UI: adds rows
pkg/klock/klock.go - Resource printer → Status coloring: uses styles
pkg/klock/color.go - Resource printer → Output formatting: parses values
pkg/klock/klock.go - Terminal table UI → Key bindings: handles keys
pkg/table/table.go - Terminal table UI → Row model: renders rows
pkg/table/table.go - Watch runtime → Duration parsing: parses durations
pkg/klock/klock.go - Optional duration → Duration parsing: parses values
pkg/types/optionalduration.go - Terminal table UI → Optional duration: uses option
pkg/table/table.go - Output formatting → String splitting: uses splitting
pkg/klock/parsing.go - Watch runtime → Watch decoding: decodes events