polish(v0.5.4): invocation-name audit + targeted regression tests
Audit walked every cmd/ and internal/ file that produces user-facing
output. All command-form hints (text the user is meant to type back)
were already routed through invocationName() in v0.5.3 — the audit is
a verification pass, not a code rewrite.
Additions:
- Extract formatResumeRestoreHint and formatDirectModeTmuxHint as
testable string-only helpers. Production paths are unchanged
behaviorally; the helpers exist purely so the audit can pin down
the format strings without simulating tmux or stderr capture.
- Two new tests pinning the invocation name to a non-canonical value
("my-bin"). The pre-existing tests already protect these surfaces
but pin the name to "ctask", so they cannot detect a regression
that hard-codes "ctask" inside the format string. The new tests
flush that out for the resume restore hint and the Layer-1
active-session attach hint.
- Drop the duplicated withInvocationName helper accidentally added in
the info-session tests; reuse the canonical helper from
persistent_test.go.
Product-identity references ("ctask persistent mode requires tmux",
the SSH-remote `ssh -t <host> ctask <subcmd>` hint, doctor's "[ctask]"
diagnostic prefix, root-command Use:/Long:) deliberately remain
literal per spec §2.
This commit is contained in:
+17
-3
@@ -58,9 +58,7 @@ func doResume(query string, container, useShell, force bool, agentOverride strin
|
||||
ws := resolveOne(roots, query, true)
|
||||
|
||||
if ws.Meta.Status == "archived" {
|
||||
fmt.Fprintf(os.Stderr,
|
||||
"[ctask] error: workspace %q is archived\n\nTo restore it:\n %s restore %s\n",
|
||||
query, invocationName(), query)
|
||||
fmt.Fprint(os.Stderr, formatResumeRestoreHint(query))
|
||||
return fmt.Errorf("workspace archived")
|
||||
}
|
||||
|
||||
@@ -88,3 +86,19 @@ func doResume(query string, container, useShell, force bool, agentOverride strin
|
||||
CommandName: "resume",
|
||||
})
|
||||
}
|
||||
|
||||
// formatResumeRestoreHint builds the multi-line stderr block printed
|
||||
// when `ctask resume <query>` resolves to an archived workspace.
|
||||
// Extracted so the v0.5.4 invocation-name audit can verify the
|
||||
// command-form line uses invocationName() without depending on the
|
||||
// surrounding fmt.Fprintf machinery.
|
||||
//
|
||||
// The "[ctask]" diagnostic prefix is intentionally a literal product
|
||||
// reference (spec §2: product-identity references stay literal). The
|
||||
// `restore <query>` line is the command-form portion and uses
|
||||
// invocationName().
|
||||
func formatResumeRestoreHint(query string) string {
|
||||
return fmt.Sprintf(
|
||||
"[ctask] error: workspace %q is archived\n\nTo restore it:\n %s restore %s\n",
|
||||
query, invocationName(), query)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user