feat(v0.5.2): direct lookup includes archived; resume hint for archived
Apply the v0.5.2 lookup policy to the existing commands and wire
ValidArgsFunction hooks across the workspace-accepting surface.
info: drop the --all/-a flag entirely. Direct lookup is now
archived-inclusive by default — the user typed a name, so we find
the workspace and surface its status in the output. The Status
line already distinguishes active vs archived clearly.
resume: when targeting an archived workspace, fail with a useful
hint instead of letting the resolver report "not found":
[ctask] error: workspace "X" is archived
To restore it:
ctask restore X
This is implemented by resolving archived-inclusive and rejecting
status==archived before any session-launch logic runs. Genuine
not-found and ambiguous-match behavior are unchanged.
Adds ValidArgsFunction hooks to archive (active), delete (active),
open (active), info (any), resume (active). Restore/notes/path
already have hooks from the previous commit. Shell completion now
covers the full direct-lookup surface.
This commit is contained in:
+14
-1
@@ -2,6 +2,7 @@ package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
@@ -32,6 +33,7 @@ func init() {
|
||||
resumeCmd.Flags().BoolVar(&resumeShell, "shell", false, "Open shell instead of agent")
|
||||
resumeCmd.Flags().StringVarP(&resumeAgent, "agent", "a", "", "Override agent command")
|
||||
resumeCmd.Flags().BoolVar(&resumeForce, "force", false, "Skip active-session and stale-workspace warnings")
|
||||
resumeCmd.ValidArgsFunction = completeWorkspaces(completionActive)
|
||||
rootCmd.AddCommand(resumeCmd)
|
||||
}
|
||||
|
||||
@@ -47,7 +49,18 @@ func doResume(query string, container, useShell, force bool, agentOverride strin
|
||||
}
|
||||
|
||||
roots := config.SearchRoots()
|
||||
ws := resolveOne(roots, query, false)
|
||||
// v0.5.2: resolve archived-inclusive so we can give a helpful hint when
|
||||
// the user resumes an archived workspace. resolveOne still handles
|
||||
// not-found and ambiguity exactly as before — this only changes which
|
||||
// workspaces are reachable, not how lookup failures are reported.
|
||||
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 ctask restore %s\n",
|
||||
query, query)
|
||||
return fmt.Errorf("workspace archived")
|
||||
}
|
||||
|
||||
// Update updated_at
|
||||
now := time.Now().UTC().Truncate(time.Second)
|
||||
|
||||
Reference in New Issue
Block a user