Conversation
Add --watch/-w flag support to all three get subcommands (task, taskspawner, workspace) for real-time resource monitoring. When enabled, the command prints the initial table then polls every 2 seconds, printing a new row whenever a resource changes. The watch flag is restricted to list mode (no name argument) and default table output (not yaml/json) to keep the behavior clear. Update all example READMEs and documentation to use `axon get -w` instead of `kubectl get -w` for a consistent CLI experience. Closes #249 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
2 issues found across 11 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="internal/cli/watch_test.go">
<violation number="1" location="internal/cli/watch_test.go:186">
P2: Weak test assertion: the check for `"5"` (TotalTasksCreated) is always satisfied by the cron schedule `"*/5 * * * *"` in the source field, so this assertion doesn't actually verify that TotalTasksCreated is rendered. Use a more distinctive value or check for the exact formatted field.</violation>
</file>
<file name="internal/cli/watch.go">
<violation number="1" location="internal/cli/watch.go:172">
P2: Watch rows will be misaligned with the initial table header. The `printTask*Table` functions use `tabwriter` to align columns, but these `printRow` functions write raw tab-separated text directly to `os.Stdout`. The tabs won't align with the `tabwriter`-formatted header. Consider either using a shared `tabwriter` that's flushed after each row, or switching to fixed-width `fmt.Fprintf` formatting for both the table and the rows.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| if !strings.Contains(output, "10") { | ||
| t.Errorf("expected discovered count in output, got %q", output) | ||
| } | ||
| if !strings.Contains(output, "5") { |
There was a problem hiding this comment.
P2: Weak test assertion: the check for "5" (TotalTasksCreated) is always satisfied by the cron schedule "*/5 * * * *" in the source field, so this assertion doesn't actually verify that TotalTasksCreated is rendered. Use a more distinctive value or check for the exact formatted field.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At internal/cli/watch_test.go, line 186:
<comment>Weak test assertion: the check for `"5"` (TotalTasksCreated) is always satisfied by the cron schedule `"*/5 * * * *"` in the source field, so this assertion doesn't actually verify that TotalTasksCreated is rendered. Use a more distinctive value or check for the exact formatted field.</comment>
<file context>
@@ -0,0 +1,276 @@
+ if !strings.Contains(output, "10") {
+ t.Errorf("expected discovered count in output, got %q", output)
+ }
+ if !strings.Contains(output, "5") {
+ t.Errorf("expected tasks created count in output, got %q", output)
+ }
</file context>
| } | ||
|
|
||
| // printTaskRow prints a single task row without the header. | ||
| func printTaskRow(w io.Writer, t *axonv1alpha1.Task, allNamespaces bool) { |
There was a problem hiding this comment.
P2: Watch rows will be misaligned with the initial table header. The printTask*Table functions use tabwriter to align columns, but these printRow functions write raw tab-separated text directly to os.Stdout. The tabs won't align with the tabwriter-formatted header. Consider either using a shared tabwriter that's flushed after each row, or switching to fixed-width fmt.Fprintf formatting for both the table and the rows.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At internal/cli/watch.go, line 172:
<comment>Watch rows will be misaligned with the initial table header. The `printTask*Table` functions use `tabwriter` to align columns, but these `printRow` functions write raw tab-separated text directly to `os.Stdout`. The tabs won't align with the `tabwriter`-formatted header. Consider either using a shared `tabwriter` that's flushed after each row, or switching to fixed-width `fmt.Fprintf` formatting for both the table and the rows.</comment>
<file context>
@@ -0,0 +1,213 @@
+}
+
+// printTaskRow prints a single task row without the header.
+func printTaskRow(w io.Writer, t *axonv1alpha1.Task, allNamespaces bool) {
+ age := duration.HumanDuration(time.Since(t.CreationTimestamp.Time))
+ if allNamespaces {
</file context>
Summary
--watch/-wflag toaxon get task,axon get taskspawner, andaxon get workspacecommands for real-time resource monitoring via polling--watchto list mode only (not with a specific name) and default table output (not--output yaml/json)axon get tasks -winstead ofkubectl get tasks -wTest plan
--watchflag validation (watch + output, watch + name rejected for all 3 resource types)printTaskRow,printTaskSpawnerRow,printWorkspaceRow)make testpassesmake verifypassesmake buildpassesaxon get tasks -win a cluster with running tasksCloses #249
🤖 Generated with Claude Code
Summary by cubic
Adds a --watch/-w flag to axon get task|taskspawner|workspace for real-time table updates, enabling simple live monitoring via polling. Aligns with #249 by replacing kubectl -w usage in docs.
New Features
Migration
Written for commit 07cad35. Summary will update on new commits.