From 99cc13f5e059eabae51e80f2816c0556f35f0d28 Mon Sep 17 00:00:00 2001 From: marco Date: Mon, 23 Sep 2024 21:50:20 +0200 Subject: [PATCH] cobra.ExactArgs(0) -> cobra.NoArgs --- cmd/crowdsec-cli/clialert/alerts.go | 2 +- cmd/crowdsec-cli/clibouncer/bouncers.go | 2 +- cmd/crowdsec-cli/clidecision/decisions.go | 4 ++-- cmd/crowdsec-cli/cliexplain/explain.go | 2 +- cmd/crowdsec-cli/clihub/hub.go | 10 +++++----- cmd/crowdsec-cli/clihubtest/hubtest.go | 2 +- cmd/crowdsec-cli/climetrics/list.go | 2 +- cmd/crowdsec-cli/climetrics/metrics.go | 2 +- cmd/crowdsec-cli/clinotifications/notifications.go | 2 +- cmd/crowdsec-cli/config.go | 2 +- cmd/crowdsec-cli/config_feature_flags.go | 2 +- cmd/crowdsec-cli/config_show.go | 2 +- cmd/crowdsec-cli/config_showyaml.go | 2 +- cmd/crowdsec-cli/dashboard.go | 10 +++++----- 14 files changed, 23 insertions(+), 23 deletions(-) diff --git a/cmd/crowdsec-cli/clialert/alerts.go b/cmd/crowdsec-cli/clialert/alerts.go index 75454e945f2..425b9860fc9 100644 --- a/cmd/crowdsec-cli/clialert/alerts.go +++ b/cmd/crowdsec-cli/clialert/alerts.go @@ -465,7 +465,7 @@ cscli alerts delete --range 1.2.3.0/24 cscli alerts delete -s crowdsecurity/ssh-bf"`, DisableAutoGenTag: true, Aliases: []string{"remove"}, - Args: cobra.ExactArgs(0), + Args: cobra.NoArgs, PreRunE: func(cmd *cobra.Command, _ []string) error { if deleteAll { return nil diff --git a/cmd/crowdsec-cli/clibouncer/bouncers.go b/cmd/crowdsec-cli/clibouncer/bouncers.go index 226fbb7e922..960f6a60815 100644 --- a/cmd/crowdsec-cli/clibouncer/bouncers.go +++ b/cmd/crowdsec-cli/clibouncer/bouncers.go @@ -198,7 +198,7 @@ func (cli *cliBouncers) newListCmd() *cobra.Command { Use: "list", Short: "list all bouncers within the database", Example: `cscli bouncers list`, - Args: cobra.ExactArgs(0), + Args: cobra.NoArgs, DisableAutoGenTag: true, RunE: func(cmd *cobra.Command, _ []string) error { return cli.List(cmd.Context(), color.Output, cli.db) diff --git a/cmd/crowdsec-cli/clidecision/decisions.go b/cmd/crowdsec-cli/clidecision/decisions.go index 1f8781a3716..307cabffe51 100644 --- a/cmd/crowdsec-cli/clidecision/decisions.go +++ b/cmd/crowdsec-cli/clidecision/decisions.go @@ -290,7 +290,7 @@ cscli decisions list -r 1.2.3.0/24 cscli decisions list -s crowdsecurity/ssh-bf cscli decisions list --origin lists --scenario list_name `, - Args: cobra.ExactArgs(0), + Args: cobra.NoArgs, DisableAutoGenTag: true, RunE: func(cmd *cobra.Command, _ []string) error { return cli.list(cmd.Context(), filter, NoSimu, contained, printMachine) @@ -416,7 +416,7 @@ cscli decisions add --ip 1.2.3.4 --duration 24h --type captcha cscli decisions add --scope username --value foobar `, /*TBD : fix long and example*/ - Args: cobra.ExactArgs(0), + Args: cobra.NoArgs, DisableAutoGenTag: true, RunE: func(cmd *cobra.Command, _ []string) error { return cli.add(cmd.Context(), addIP, addRange, addDuration, addValue, addScope, addReason, addType) diff --git a/cmd/crowdsec-cli/cliexplain/explain.go b/cmd/crowdsec-cli/cliexplain/explain.go index 182e34a12a5..c7337a86024 100644 --- a/cmd/crowdsec-cli/cliexplain/explain.go +++ b/cmd/crowdsec-cli/cliexplain/explain.go @@ -80,7 +80,7 @@ cscli explain --log "Sep 19 18:33:22 scw-d95986 sshd[24347]: pam_unix(sshd:auth) cscli explain --dsn "file://myfile.log" --type nginx tail -n 5 myfile.log | cscli explain --type nginx -f - `, - Args: cobra.ExactArgs(0), + Args: cobra.NoArgs, DisableAutoGenTag: true, RunE: func(_ *cobra.Command, _ []string) error { return cli.run() diff --git a/cmd/crowdsec-cli/clihub/hub.go b/cmd/crowdsec-cli/clihub/hub.go index 22568355546..f189d6a2e13 100644 --- a/cmd/crowdsec-cli/clihub/hub.go +++ b/cmd/crowdsec-cli/clihub/hub.go @@ -39,7 +39,7 @@ The Hub is managed by cscli, to get the latest hub files from [Crowdsec Hub](htt Example: `cscli hub list cscli hub update cscli hub upgrade`, - Args: cobra.ExactArgs(0), + Args: cobra.NoArgs, DisableAutoGenTag: true, } @@ -87,7 +87,7 @@ func (cli *cliHub) newListCmd() *cobra.Command { cmd := &cobra.Command{ Use: "list [-a]", Short: "List all installed configurations", - Args: cobra.ExactArgs(0), + Args: cobra.NoArgs, DisableAutoGenTag: true, RunE: func(_ *cobra.Command, _ []string) error { hub, err := require.Hub(cli.cfg(), nil, log.StandardLogger()) @@ -140,7 +140,7 @@ func (cli *cliHub) newUpdateCmd() *cobra.Command { Long: ` Fetches the .index.json file from the hub, containing the list of available configs. `, - Args: cobra.ExactArgs(0), + Args: cobra.NoArgs, DisableAutoGenTag: true, RunE: func(cmd *cobra.Command, _ []string) error { return cli.update(cmd.Context(), withContent) @@ -190,7 +190,7 @@ func (cli *cliHub) newUpgradeCmd() *cobra.Command { Long: ` Upgrade all configs installed from Crowdsec Hub. Run 'sudo cscli hub update' if you want the latest versions available. `, - Args: cobra.ExactArgs(0), + Args: cobra.NoArgs, DisableAutoGenTag: true, RunE: func(cmd *cobra.Command, _ []string) error { return cli.upgrade(cmd.Context(), force) @@ -235,7 +235,7 @@ func (cli *cliHub) newTypesCmd() *cobra.Command { Long: ` List the types of supported hub items. `, - Args: cobra.ExactArgs(0), + Args: cobra.NoArgs, DisableAutoGenTag: true, RunE: func(_ *cobra.Command, _ []string) error { return cli.types() diff --git a/cmd/crowdsec-cli/clihubtest/hubtest.go b/cmd/crowdsec-cli/clihubtest/hubtest.go index 3420e21e1e2..f4cfed2e1cb 100644 --- a/cmd/crowdsec-cli/clihubtest/hubtest.go +++ b/cmd/crowdsec-cli/clihubtest/hubtest.go @@ -39,7 +39,7 @@ func (cli *cliHubTest) NewCommand() *cobra.Command { Use: "hubtest", Short: "Run functional tests on hub configurations", Long: "Run functional tests on hub configurations (parsers, scenarios, collections...)", - Args: cobra.ExactArgs(0), + Args: cobra.NoArgs, DisableAutoGenTag: true, PersistentPreRunE: func(_ *cobra.Command, _ []string) error { var err error diff --git a/cmd/crowdsec-cli/climetrics/list.go b/cmd/crowdsec-cli/climetrics/list.go index ddb2baac14d..27fa99710c8 100644 --- a/cmd/crowdsec-cli/climetrics/list.go +++ b/cmd/crowdsec-cli/climetrics/list.go @@ -84,7 +84,7 @@ func (cli *cliMetrics) newListCmd() *cobra.Command { Use: "list", Short: "List available types of metrics.", Long: `List available types of metrics.`, - Args: cobra.ExactArgs(0), + Args: cobra.NoArgs, DisableAutoGenTag: true, RunE: func(_ *cobra.Command, _ []string) error { return cli.list() diff --git a/cmd/crowdsec-cli/climetrics/metrics.go b/cmd/crowdsec-cli/climetrics/metrics.go index f3bc4874460..67bd7b6ad93 100644 --- a/cmd/crowdsec-cli/climetrics/metrics.go +++ b/cmd/crowdsec-cli/climetrics/metrics.go @@ -36,7 +36,7 @@ cscli metrics --url http://lapi.local:6060/metrics show acquisition parsers # List available metric types cscli metrics list`, - Args: cobra.ExactArgs(0), + Args: cobra.NoArgs, DisableAutoGenTag: true, RunE: func(cmd *cobra.Command, _ []string) error { return cli.show(cmd.Context(), nil, url, noUnit) diff --git a/cmd/crowdsec-cli/clinotifications/notifications.go b/cmd/crowdsec-cli/clinotifications/notifications.go index 5489faa37c8..baf899c10cf 100644 --- a/cmd/crowdsec-cli/clinotifications/notifications.go +++ b/cmd/crowdsec-cli/clinotifications/notifications.go @@ -158,7 +158,7 @@ func (cli *cliNotifications) newListCmd() *cobra.Command { Short: "list notifications plugins", Long: `list notifications plugins and their status (active or not)`, Example: `cscli notifications list`, - Args: cobra.ExactArgs(0), + Args: cobra.NoArgs, DisableAutoGenTag: true, RunE: func(_ *cobra.Command, _ []string) error { cfg := cli.cfg() diff --git a/cmd/crowdsec-cli/config.go b/cmd/crowdsec-cli/config.go index e88845798e2..4cf8916ad4b 100644 --- a/cmd/crowdsec-cli/config.go +++ b/cmd/crowdsec-cli/config.go @@ -18,7 +18,7 @@ func (cli *cliConfig) NewCommand() *cobra.Command { cmd := &cobra.Command{ Use: "config [command]", Short: "Allows to view current config", - Args: cobra.ExactArgs(0), + Args: cobra.NoArgs, DisableAutoGenTag: true, } diff --git a/cmd/crowdsec-cli/config_feature_flags.go b/cmd/crowdsec-cli/config_feature_flags.go index d1dbe2b93b7..760e2194bb3 100644 --- a/cmd/crowdsec-cli/config_feature_flags.go +++ b/cmd/crowdsec-cli/config_feature_flags.go @@ -121,7 +121,7 @@ func (cli *cliConfig) newFeatureFlagsCmd() *cobra.Command { Use: "feature-flags", Short: "Displays feature flag status", Long: `Displays the supported feature flags and their current status.`, - Args: cobra.ExactArgs(0), + Args: cobra.NoArgs, DisableAutoGenTag: true, RunE: func(_ *cobra.Command, _ []string) error { return cli.featureFlags(showRetired) diff --git a/cmd/crowdsec-cli/config_show.go b/cmd/crowdsec-cli/config_show.go index 2d3ac488ba2..3d17d264574 100644 --- a/cmd/crowdsec-cli/config_show.go +++ b/cmd/crowdsec-cli/config_show.go @@ -235,7 +235,7 @@ func (cli *cliConfig) newShowCmd() *cobra.Command { Use: "show", Short: "Displays current config", Long: `Displays the current cli configuration.`, - Args: cobra.ExactArgs(0), + Args: cobra.NoArgs, DisableAutoGenTag: true, RunE: func(_ *cobra.Command, _ []string) error { if err := cli.cfg().LoadAPIClient(); err != nil { diff --git a/cmd/crowdsec-cli/config_showyaml.go b/cmd/crowdsec-cli/config_showyaml.go index 52daee6a65e..10549648d09 100644 --- a/cmd/crowdsec-cli/config_showyaml.go +++ b/cmd/crowdsec-cli/config_showyaml.go @@ -15,7 +15,7 @@ func (cli *cliConfig) newShowYAMLCmd() *cobra.Command { cmd := &cobra.Command{ Use: "show-yaml", Short: "Displays merged config.yaml + config.yaml.local", - Args: cobra.ExactArgs(0), + Args: cobra.NoArgs, DisableAutoGenTag: true, RunE: func(_ *cobra.Command, _ []string) error { return cli.showYAML() diff --git a/cmd/crowdsec-cli/dashboard.go b/cmd/crowdsec-cli/dashboard.go index 41db9e6cbf2..53a7dff85a0 100644 --- a/cmd/crowdsec-cli/dashboard.go +++ b/cmd/crowdsec-cli/dashboard.go @@ -129,7 +129,7 @@ func (cli *cliDashboard) newSetupCmd() *cobra.Command { Use: "setup", Short: "Setup a metabase container.", Long: `Perform a metabase docker setup, download standard dashboards, create a fresh user and start the container`, - Args: cobra.ExactArgs(0), + Args: cobra.NoArgs, DisableAutoGenTag: true, Example: ` cscli dashboard setup @@ -198,7 +198,7 @@ func (cli *cliDashboard) newStartCmd() *cobra.Command { Use: "start", Short: "Start the metabase container.", Long: `Stats the metabase container using docker.`, - Args: cobra.ExactArgs(0), + Args: cobra.NoArgs, DisableAutoGenTag: true, RunE: func(_ *cobra.Command, _ []string) error { mb, err := metabase.NewMetabase(metabaseConfigPath, metabaseContainerID) @@ -229,7 +229,7 @@ func (cli *cliDashboard) newStopCmd() *cobra.Command { Use: "stop", Short: "Stops the metabase container.", Long: `Stops the metabase container using docker.`, - Args: cobra.ExactArgs(0), + Args: cobra.NoArgs, DisableAutoGenTag: true, RunE: func(_ *cobra.Command, _ []string) error { if err := metabase.StopContainer(metabaseContainerID); err != nil { @@ -245,7 +245,7 @@ func (cli *cliDashboard) newStopCmd() *cobra.Command { func (cli *cliDashboard) newShowPasswordCmd() *cobra.Command { cmd := &cobra.Command{Use: "show-password", Short: "displays password of metabase.", - Args: cobra.ExactArgs(0), + Args: cobra.NoArgs, DisableAutoGenTag: true, RunE: func(_ *cobra.Command, _ []string) error { m := metabase.Metabase{} @@ -268,7 +268,7 @@ func (cli *cliDashboard) newRemoveCmd() *cobra.Command { Use: "remove", Short: "removes the metabase container.", Long: `removes the metabase container using docker.`, - Args: cobra.ExactArgs(0), + Args: cobra.NoArgs, DisableAutoGenTag: true, Example: ` cscli dashboard remove