-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommand_config.go
More file actions
37 lines (32 loc) · 914 Bytes
/
Copy pathcommand_config.go
File metadata and controls
37 lines (32 loc) · 914 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package contexting
import "github.com/spf13/cobra"
func newConfigCommand() *cobra.Command {
cfgCmd := &cobra.Command{
Use: "config",
Short: "Manage .ctxt/ctx_config.toml configuration",
}
cfgCmd.AddCommand(newConfigInitCommand())
return cfgCmd
}
func newConfigInitCommand() *cobra.Command {
var outPath string
var force bool
cmd := &cobra.Command{
Use: "init",
Short: "Create starter .ctxt/ctx_config.toml",
RunE: func(cmd *cobra.Command, args []string) error {
target := outPath
if target == "" {
target = configPath
}
if err := writeStarterConfig(target, force); err != nil {
return err
}
LogInfof("Created starter config at %s", target)
return nil
},
}
cmd.Flags().StringVar(&outPath, "output", "", "Path to write starter config (defaults to --config path)")
cmd.Flags().BoolVar(&force, "force", false, "Overwrite existing config file")
return cmd
}