crowdsec/cmd/crowdsec-cli/cliconfig/config.go
mmetc b12ade27f4
cscli: review/update argument number checking (#3490)
* cscsli: remove unused Command.Args setting

* cscli: review/update argument number checking

cscli will consistently print the help text if the number of arguments is
wrong for the command, but not for other types of errors.

* fix func tests

* lint
2025-03-04 12:21:27 +01:00

37 lines
772 B
Go

package cliconfig
import (
"github.com/spf13/cobra"
"github.com/crowdsecurity/crowdsec/pkg/csconfig"
)
type configGetter func() *csconfig.Config
type mergedConfigGetter func() string
type cliConfig struct {
cfg configGetter
}
func New(cfg configGetter) *cliConfig {
return &cliConfig{
cfg: cfg,
}
}
func (cli *cliConfig) NewCommand(mergedConfigGetter mergedConfigGetter) *cobra.Command {
cmd := &cobra.Command{
Use: "config [command]",
Short: "Allows to view current config",
DisableAutoGenTag: true,
}
cmd.AddCommand(cli.newShowCmd())
cmd.AddCommand(cli.newShowYAMLCmd(mergedConfigGetter))
cmd.AddCommand(cli.newBackupCmd())
cmd.AddCommand(cli.newRestoreCmd())
cmd.AddCommand(cli.newFeatureFlagsCmd())
return cmd
}