Files
ctask/cmd/archive.go
T
typebasedio 0c1f03ba3a fix(v0.4.1): route all workspace commands through SearchRoots
Every resolver, lister, and most-recent caller now passes
config.SearchRoots() so CTASK_PROJECT_ROOT is searched alongside
CTASK_ROOT. Commands use ws.Root when rendering relative paths or
session env vars so displays and CTASK_ROOT exports are correct for
workspaces living under CTASK_PROJECT_ROOT.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 17:54:58 -04:00

44 lines
985 B
Go

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),
SilenceUsage: true,
RunE: runArchive,
}
func init() {
rootCmd.AddCommand(archiveCmd)
}
func runArchive(cmd *cobra.Command, args []string) error {
roots := config.SearchRoots()
ws := resolveOne(roots, 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.WriteMetaLocked(metaPath, ws.Meta); err != nil {
return fmt.Errorf("updating metadata: %w", err)
}
relPath := workspace.RelativePath(ws.Root, ws.Path)
fmt.Printf("[ctask] archived: %s\n", relPath)
return nil
}