Skip to content

Add --watch flag to axon get commands#347

Closed
axon-agent[bot] wants to merge 1 commit intomainfrom
axon-task-249
Closed

Add --watch flag to axon get commands#347
axon-agent[bot] wants to merge 1 commit intomainfrom
axon-task-249

Conversation

@axon-agent
Copy link

@axon-agent axon-agent bot commented Feb 15, 2026

Summary

  • Add --watch/-w flag to axon get task, axon get taskspawner, and axon get workspace commands for real-time resource monitoring via polling
  • Print the initial table, then poll every 2 seconds and print a new row when a resource's state changes (phase, discovered count, etc.)
  • Restrict --watch to list mode only (not with a specific name) and default table output (not --output yaml/json)
  • Update all example READMEs and documentation to use axon get tasks -w instead of kubectl get tasks -w

Test plan

  • Unit tests for --watch flag validation (watch + output, watch + name rejected for all 3 resource types)
  • Unit tests for row printing functions (printTaskRow, printTaskSpawnerRow, printWorkspaceRow)
  • make test passes
  • make verify passes
  • make build passes
  • Manual testing: axon get tasks -w in a cluster with running tasks

Closes #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

    • --watch/-w prints the initial table, then appends a row on changes; polls every 2s.
    • Works only in list mode and default table output; rejected with --output or a resource name.
  • Migration

    • Use axon get tasks -w (and taskspawners -w, workspaces -w) instead of kubectl get ... -w.
    • Watching does not support YAML/JSON output.

Written for commit 07cad35. Summary will update on new commits.

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>
Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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") {
Copy link

@cubic-dev-ai cubic-dev-ai bot Feb 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Fix with Cubic

}

// printTaskRow prints a single task row without the header.
func printTaskRow(w io.Writer, t *axonv1alpha1.Task, allNamespaces bool) {
Copy link

@cubic-dev-ai cubic-dev-ai bot Feb 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Fix with Cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI: 'axon get' commands missing --watch flag for real-time monitoring

1 participant