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)
|
||||||
|
}
|
||||||
2
testdata/help.ct
vendored
2
testdata/help.ct
vendored
|
|
@ -36,6 +36,7 @@ Git commands:
|
||||||
|
|
||||||
Additional Commands:
|
Additional Commands:
|
||||||
completion Generate the autocompletion script for the specified shell
|
completion Generate the autocompletion script for the specified shell
|
||||||
|
config View and modify configuration
|
||||||
doctor Check environment health
|
doctor Check environment health
|
||||||
help Help about any command
|
help Help about any command
|
||||||
version Display pda! version
|
version Display pda! version
|
||||||
|
|
@ -80,6 +81,7 @@ Git commands:
|
||||||
|
|
||||||
Additional Commands:
|
Additional Commands:
|
||||||
completion Generate the autocompletion script for the specified shell
|
completion Generate the autocompletion script for the specified shell
|
||||||
|
config View and modify configuration
|
||||||
doctor Check environment health
|
doctor Check environment health
|
||||||
help Help about any command
|
help Help about any command
|
||||||
version Display pda! version
|
version Display pda! version
|
||||||
|
|
|
||||||
1
testdata/root.ct
vendored
1
testdata/root.ct
vendored
|
|
@ -35,6 +35,7 @@ Git commands:
|
||||||
|
|
||||||
Additional Commands:
|
Additional Commands:
|
||||||
completion Generate the autocompletion script for the specified shell
|
completion Generate the autocompletion script for the specified shell
|
||||||
|
config View and modify configuration
|
||||||
doctor Check environment health
|
doctor Check environment health
|
||||||
help Help about any command
|
help Help about any command
|
||||||
version Display pda! version
|
version Display pda! version
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue