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:
2026-04-05 18:34:40 -04:00
parent afd594ed6c
commit 50e7333e84
7 changed files with 401 additions and 0 deletions
+42
View File
@@ -0,0 +1,42 @@
package cmd
import (
"fmt"
"path/filepath"
"time"
"github.com/spf13/cobra"
"github.com/warrenronsiek/ctask/internal/config"
"github.com/warrenronsiek/ctask/internal/workspace"
)
var archiveCmd = &cobra.Command{
Use: "archive <query>",
Short: "Mark a workspace as archived",
Args: cobra.ExactArgs(1),
RunE: runArchive,
}
func init() {
rootCmd.AddCommand(archiveCmd)
}
func runArchive(cmd *cobra.Command, args []string) error {
root := config.ResolveRoot()
ws := resolveOne(root, args[0], false)
now := time.Now().UTC().Truncate(time.Second)
ws.Meta.Status = "archived"
ws.Meta.ArchivedAt = &now
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)
}
relPath := workspace.RelativePath(root, ws.Path)
fmt.Printf("[ctask] archived: %s\n", relPath)
return nil
}