feat: all six CLI commands (new, list, resume, open, info, archive)
Complete command implementations with all flags per spec. Shared query resolution helper. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
+44
@@ -0,0 +1,44 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/warrenronsiek/ctask/internal/config"
|
||||
"github.com/warrenronsiek/ctask/internal/shell"
|
||||
"github.com/warrenronsiek/ctask/internal/workspace"
|
||||
)
|
||||
|
||||
var openCmd = &cobra.Command{
|
||||
Use: "open <query>",
|
||||
Short: "Open a workspace directory without launching the agent",
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: runOpen,
|
||||
}
|
||||
|
||||
var openAll bool
|
||||
|
||||
func init() {
|
||||
openCmd.Flags().BoolVarP(&openAll, "all", "a", false, "Include archived workspaces in query resolution")
|
||||
rootCmd.AddCommand(openCmd)
|
||||
}
|
||||
|
||||
func runOpen(cmd *cobra.Command, args []string) error {
|
||||
root := config.ResolveRoot()
|
||||
ws := resolveOne(root, args[0], openAll)
|
||||
|
||||
// Update updated_at
|
||||
now := time.Now().UTC().Truncate(time.Second)
|
||||
ws.Meta.UpdatedAt = now
|
||||
metaPath := filepath.Join(ws.Path, "task.yaml")
|
||||
if err := workspace.WriteMeta(metaPath, ws.Meta); err != nil {
|
||||
return fmt.Errorf("updating metadata: %w", err)
|
||||
}
|
||||
|
||||
envVars := config.EnvVars(ws.Meta.Slug, ws.Meta.Mode, root, ws.Path, ws.Meta.Category)
|
||||
|
||||
// Spawn interactive subshell (not agent, not cd in parent)
|
||||
return shell.ExecShell(ws.Path, envVars, ws.Meta.Slug, ws.Meta.Mode)
|
||||
}
|
||||
Reference in New Issue
Block a user