|
| 1 | +package cmd |
| 2 | + |
| 3 | +import ( |
| 4 | + "fmt" |
| 5 | + |
| 6 | + "github.com/spf13/cobra" |
| 7 | +) |
| 8 | + |
| 9 | +type configDescription struct { |
| 10 | + Type string |
| 11 | + Description string |
| 12 | + Example string |
| 13 | + Default string |
| 14 | +} |
| 15 | + |
| 16 | +var configDescriptions = map[string]configDescription{ |
| 17 | + "defaults.agent": { |
| 18 | + Type: "String (Agent Name or ID)", |
| 19 | + Description: "Specifies the default agent to use when running `construct new` without the\n --agent flag. This allows you to set a preferred agent for new conversations.", |
| 20 | + Example: "construct config set defaults.agent \"my-favorite-coder\"", |
| 21 | + }, |
| 22 | +} |
| 23 | + |
| 24 | +func NewConfigDescribeCmd() *cobra.Command { |
| 25 | + cmd := &cobra.Command{ |
| 26 | + Use: "describe <key>", |
| 27 | + Short: "Describe a configuration value", |
| 28 | + Long: `The "describe" command allows you to describe a configuration value`, |
| 29 | + Args: cobra.ExactArgs(1), |
| 30 | + RunE: func(cmd *cobra.Command, args []string) error { |
| 31 | + key := args[0] |
| 32 | + description, ok := configDescriptions[key] |
| 33 | + if !ok { |
| 34 | + return fmt.Errorf("unknown configuration key: %s", key) |
| 35 | + } |
| 36 | + |
| 37 | + defaultValue := description.Default |
| 38 | + if defaultValue == "" { |
| 39 | + defaultValue = "(none)" |
| 40 | + } |
| 41 | + |
| 42 | + fmt.Printf("%s\n\n", key) |
| 43 | + fmt.Printf(" %s\n\n", description.Description) |
| 44 | + fmt.Printf(" Type Default\n") |
| 45 | + fmt.Printf(" %-28s %s\n\n", description.Type, defaultValue) |
| 46 | + fmt.Printf(" Example: %s\n", description.Example) |
| 47 | + |
| 48 | + return nil |
| 49 | + }, |
| 50 | + } |
| 51 | + |
| 52 | + return cmd |
| 53 | +} |
0 commit comments