From e4a5e7f71501103daf095f91e69d01b144772a36 Mon Sep 17 00:00:00 2001 From: lew Date: Wed, 11 Feb 2026 23:34:20 +0000 Subject: [PATCH] feat(config): add config parent command and path subcommand --- cmd/config_cmd.go | 32 ++++++++++++++++++++++++++++++++ testdata/help.ct | 2 ++ testdata/root.ct | 1 + 3 files changed, 35 insertions(+) create mode 100644 cmd/config_cmd.go diff --git a/cmd/config_cmd.go b/cmd/config_cmd.go new file mode 100644 index 0000000..802e815 --- /dev/null +++ b/cmd/config_cmd.go @@ -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) +} diff --git a/testdata/help.ct b/testdata/help.ct index 530fc3d..cc7e94b 100644 --- a/testdata/help.ct +++ b/testdata/help.ct @@ -36,6 +36,7 @@ Git commands: Additional Commands: completion Generate the autocompletion script for the specified shell + config View and modify configuration doctor Check environment health help Help about any command version Display pda! version @@ -80,6 +81,7 @@ Git commands: Additional Commands: completion Generate the autocompletion script for the specified shell + config View and modify configuration doctor Check environment health help Help about any command version Display pda! version diff --git a/testdata/root.ct b/testdata/root.ct index fe8496e..1370ab8 100644 --- a/testdata/root.ct +++ b/testdata/root.ct @@ -35,6 +35,7 @@ Git commands: Additional Commands: completion Generate the autocompletion script for the specified shell + config View and modify configuration doctor Check environment health help Help about any command version Display pda! version