57f345ae2b
Exit 2 for missing required arguments, exit 127 for agent not found. SilenceUsage on all commands to avoid dumping usage on runtime errors. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
62 lines
1.4 KiB
Go
62 lines
1.4 KiB
Go
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/spf13/cobra"
|
|
"github.com/warrenronsiek/ctask/internal/config"
|
|
)
|
|
|
|
var infoCmd = &cobra.Command{
|
|
Use: "info <query>",
|
|
Short: "Display metadata and path for a workspace",
|
|
Args: cobra.ExactArgs(1),
|
|
SilenceUsage: true,
|
|
RunE: runInfo,
|
|
}
|
|
|
|
var infoAll bool
|
|
|
|
func init() {
|
|
infoCmd.Flags().BoolVarP(&infoAll, "all", "a", false, "Include archived workspaces in query resolution")
|
|
rootCmd.AddCommand(infoCmd)
|
|
}
|
|
|
|
func runInfo(cmd *cobra.Command, args []string) error {
|
|
root := config.ResolveRoot()
|
|
ws := resolveOne(root, args[0], infoAll)
|
|
m := ws.Meta
|
|
|
|
fmt.Printf("Task: %s\n", m.Slug)
|
|
fmt.Printf("Title: %s\n", m.Title)
|
|
fmt.Printf("Category: %s\n", m.Category)
|
|
fmt.Printf("Status: %s\n", m.Status)
|
|
fmt.Printf("Mode: %s\n", m.Mode)
|
|
fmt.Printf("Agent: %s\n", m.Agent)
|
|
fmt.Printf("Created: %s\n", m.CreatedAt.Format("2006-01-02 15:04:05"))
|
|
fmt.Printf("Updated: %s\n", m.UpdatedAt.Format("2006-01-02 15:04:05"))
|
|
fmt.Printf("Path: %s\n", ws.Path)
|
|
|
|
if m.ArchivedAt != nil {
|
|
fmt.Printf("Archived: %s\n", m.ArchivedAt.Format("2006-01-02 15:04:05"))
|
|
}
|
|
|
|
// List contents
|
|
fmt.Println()
|
|
fmt.Println("Contents:")
|
|
entries, err := os.ReadDir(ws.Path)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
for _, e := range entries {
|
|
name := e.Name()
|
|
if e.IsDir() {
|
|
name += "/"
|
|
}
|
|
fmt.Printf(" %s\n", name)
|
|
}
|
|
|
|
return nil
|
|
}
|