Skip to content

Commit

Permalink
cscli: simplify generic item commands (#2641)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmetc authored Dec 6, 2023
1 parent 0c61726 commit fe78511
Show file tree
Hide file tree
Showing 2 changed files with 210 additions and 239 deletions.
10 changes: 5 additions & 5 deletions cmd/crowdsec-cli/appsec_rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func NewCmdAppsecRulesInstall() *cobra.Command {
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return compAllItems(cwhub.APPSEC_RULES, args, toComplete)
},

Check warning on line 66 in cmd/crowdsec-cli/appsec_rules.go

View check run for this annotation

Codecov / codecov/patch

cmd/crowdsec-cli/appsec_rules.go#L65-L66

Added lines #L65 - L66 were not covered by tests
RunE: itemsInstallRunner(hubItemTypes[cwhub.APPSEC_RULES]),
RunE: hubItemTypes[cwhub.APPSEC_RULES].Install,
}

flags := cmdAppsecRulesInstall.Flags()
Expand All @@ -86,7 +86,7 @@ func NewCmdAppsecRulesRemove() *cobra.Command {
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return compInstalledItems(cwhub.APPSEC_RULES, args, toComplete)
},

Check warning on line 88 in cmd/crowdsec-cli/appsec_rules.go

View check run for this annotation

Codecov / codecov/patch

cmd/crowdsec-cli/appsec_rules.go#L87-L88

Added lines #L87 - L88 were not covered by tests
RunE: itemsRemoveRunner(hubItemTypes[cwhub.APPSEC_RULES]),
RunE: hubItemTypes[cwhub.APPSEC_RULES].Remove,
}

flags := cmdAppsecRulesRemove.Flags()
Expand All @@ -107,7 +107,7 @@ func NewCmdAppsecRulesUpgrade() *cobra.Command {
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return compInstalledItems(cwhub.APPSEC_RULES, args, toComplete)
},

Check warning on line 109 in cmd/crowdsec-cli/appsec_rules.go

View check run for this annotation

Codecov / codecov/patch

cmd/crowdsec-cli/appsec_rules.go#L108-L109

Added lines #L108 - L109 were not covered by tests
RunE: itemsUpgradeRunner(hubItemTypes[cwhub.APPSEC_RULES]),
RunE: hubItemTypes[cwhub.APPSEC_RULES].Upgrade,
}

flags := cmdAppsecRulesUpgrade.Flags()
Expand All @@ -119,7 +119,7 @@ func NewCmdAppsecRulesUpgrade() *cobra.Command {

func AppsecRulesInspectRunner(itemType hubItemType) func(cmd *cobra.Command, args []string) error {
return func(cmd *cobra.Command, args []string) error {
f := itemsInspectRunner(hubItemTypes[cwhub.APPSEC_RULES])
f := hubItemTypes[cwhub.APPSEC_RULES].Inspect
if err := f(cmd, args); err != nil {
return err
}
Expand Down Expand Up @@ -182,7 +182,7 @@ func NewCmdAppsecRulesList() *cobra.Command {
cscli appsec-rules list -a
cscli appsec-rules list crowdsecurity/crs`,
DisableAutoGenTag: true,
RunE: itemsListRunner(hubItemTypes[cwhub.APPSEC_RULES]),
RunE: hubItemTypes[cwhub.APPSEC_RULES].List,
}

flags := cmdAppsecRulesList.Flags()
Expand Down
Loading

0 comments on commit fe78511

Please sign in to comment.