50e7333e84
Complete command implementations with all flags per spec. Shared query resolution helper. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
45 lines
1.2 KiB
Go
45 lines
1.2 KiB
Go
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)
|
|
}
|