feat(v0.5.3): cmd open -- preserve --all resolution; delegate to runWorkspaceEntry with Shell:true

This commit is contained in:
2026-05-08 14:02:03 -04:00
parent 2d3ebfbc3a
commit 5f76feecdf
2 changed files with 101 additions and 16 deletions
+17 -16
View File
@@ -7,7 +7,6 @@ import (
"github.com/spf13/cobra"
"github.com/warrenronsiek/ctask/internal/config"
"github.com/warrenronsiek/ctask/internal/session"
"github.com/warrenronsiek/ctask/internal/workspace"
)
@@ -20,23 +19,27 @@ var openCmd = &cobra.Command{
}
var (
openAll bool
openForce bool
openAll bool
openForce bool
openDirect bool
)
func init() {
openCmd.Flags().BoolVarP(&openAll, "all", "a", false, "Include archived workspaces in query resolution")
openCmd.Flags().BoolVar(&openForce, "force", false, "Skip active-session and stale-workspace warnings")
// v0.5.2: completion offers active candidates only (see delete for rationale).
openCmd.Flags().BoolVar(&openDirect, "direct", false, "Bypass persistent session mode for this command")
openCmd.ValidArgsFunction = completeWorkspaces(completionActive)
rootCmd.AddCommand(openCmd)
}
func runOpen(cmd *cobra.Command, args []string) error {
roots := config.SearchRoots()
// PRESERVED v0.5.2 behavior: open's archive resolution is opt-in via --all.
// resolveOne(roots, query, includeArchived) — distinct from resume's
// archived-inclusive-with-restore-hint behavior.
ws := resolveOne(roots, args[0], openAll)
// Update updated_at
// updated_at bump (existing v0.4 behavior).
now := time.Now().UTC().Truncate(time.Second)
ws.Meta.UpdatedAt = now
metaPath := filepath.Join(ws.Path, "task.yaml")
@@ -44,16 +47,14 @@ func runOpen(cmd *cobra.Command, args []string) error {
return fmt.Errorf("updating metadata: %w", err)
}
envVars := config.EnvVars(ws.Meta.Slug, ws.Meta.Mode, ws.Root, ws.Path, ws.Meta.Category, workspace.EffectiveType(ws.Meta), ws.Meta.LaunchDir)
return session.Run(session.LaunchOpts{
WsDir: ws.Path,
EnvVars: envVars,
Agent: ws.Meta.Agent,
Mode: ws.Meta.Mode,
Slug: ws.Meta.Slug,
Shell: true, // open always launches shell
LaunchDir: ws.Meta.LaunchDir,
Force: openForce,
return runWorkspaceEntry(WorkspaceEntryOptions{
WsPath: ws.Path,
WsRoot: ws.Root,
WsMeta: ws.Meta,
Agent: ws.Meta.Agent,
Shell: true, // open always launches a shell
Force: openForce,
Direct: openDirect,
CommandName: "open",
})
}