mirror of
https://github.com/crowdsecurity/crowdsec.git
synced 2025-05-14 13:24:34 +02:00
* 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
37 lines
772 B
Go
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
|
|
}
|