package cli import ( "fmt" "github.com/spf13/cobra" "github.com/kotoyuuko/cc-switch-cli/internal/templates" ) func newTemplatesCmd(app *appState) *cobra.Command { cmd := &cobra.Command{ Use: "templates", Short: "Inspect built-in provider templates", } cmd.AddCommand( &cobra.Command{ Use: "list", Short: "List template names", RunE: func(cmd *cobra.Command, args []string) error { for _, t := range templates.All() { fmt.Fprintf(app.stdout, "%s\t%s\n", t.Name, t.Description) } return nil }, }, &cobra.Command{ Use: "show ", Short: "Show a template's env keys, hints, and defaults", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { t, ok := templates.Get(args[0]) if !ok { return fmt.Errorf( "template %q not found; run `cc-switch templates list`", args[0]) } fmt.Fprintf(app.stdout, "%s — %s\n", t.Name, t.Description) fmt.Fprintln(app.stdout, "env:") for _, e := range t.Env { line := " " + e.Name if e.Default != "" { line += fmt.Sprintf(" [%s]", e.Default) } if e.Hint != "" { line += " # " + e.Hint } fmt.Fprintln(app.stdout, line) } return nil }, }, ) return cmd }