feat(config): add config parent command and path subcommand
This commit is contained in:
parent
3f6ddfbcd4
commit
e4a5e7f715
3 changed files with 35 additions and 0 deletions
32
cmd/config_cmd.go
Normal file
32
cmd/config_cmd.go
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var configCmd = &cobra.Command{
|
||||
Use: "config",
|
||||
Short: "View and modify configuration",
|
||||
}
|
||||
|
||||
var configPathCmd = &cobra.Command{
|
||||
Use: "path",
|
||||
Short: "Print config file path",
|
||||
Args: cobra.NoArgs,
|
||||
SilenceUsage: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
p, err := configPath()
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot determine config path: %w", err)
|
||||
}
|
||||
fmt.Println(p)
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
configCmd.AddCommand(configPathCmd)
|
||||
rootCmd.AddCommand(configCmd)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue