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 ", 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 }