Allow cscli remove to remove with --all (#1360)
This commit is contained in:
parent
42a1bc0260
commit
24797c1534
|
@ -67,12 +67,17 @@ func NewCollectionsCmd() *cobra.Command {
|
||||||
Short: "Remove given collection(s)",
|
Short: "Remove given collection(s)",
|
||||||
Long: `Remove given collection(s) from hub`,
|
Long: `Remove given collection(s) from hub`,
|
||||||
Example: `cscli collections remove crowdsec/xxx crowdsec/xyz`,
|
Example: `cscli collections remove crowdsec/xxx crowdsec/xyz`,
|
||||||
Args: cobra.MinimumNArgs(1),
|
|
||||||
DisableAutoGenTag: true,
|
DisableAutoGenTag: true,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
if all {
|
if all {
|
||||||
RemoveMany(cwhub.COLLECTIONS, "")
|
RemoveMany(cwhub.COLLECTIONS, "")
|
||||||
} else {
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(args) == 0 {
|
||||||
|
log.Fatalf("Specify at least one collection to remove or '--all' flag.")
|
||||||
|
}
|
||||||
|
|
||||||
for _, name := range args {
|
for _, name := range args {
|
||||||
if !forceAction {
|
if !forceAction {
|
||||||
item := cwhub.GetItem(cwhub.COLLECTIONS, name)
|
item := cwhub.GetItem(cwhub.COLLECTIONS, name)
|
||||||
|
@ -87,7 +92,6 @@ func NewCollectionsCmd() *cobra.Command {
|
||||||
}
|
}
|
||||||
RemoveMany(cwhub.COLLECTIONS, name)
|
RemoveMany(cwhub.COLLECTIONS, name)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
cmdCollectionsRemove.PersistentFlags().BoolVar(&purge, "purge", false, "Delete source file too")
|
cmdCollectionsRemove.PersistentFlags().BoolVar(&purge, "purge", false, "Delete source file too")
|
||||||
|
|
|
@ -70,16 +70,20 @@ cscli parsers remove crowdsecurity/sshd-logs
|
||||||
Short: "Remove given parser(s)",
|
Short: "Remove given parser(s)",
|
||||||
Long: `Remove given parse(s) from hub`,
|
Long: `Remove given parse(s) from hub`,
|
||||||
Example: `cscli parsers remove crowdsec/xxx crowdsec/xyz`,
|
Example: `cscli parsers remove crowdsec/xxx crowdsec/xyz`,
|
||||||
Args: cobra.MinimumNArgs(1),
|
|
||||||
DisableAutoGenTag: true,
|
DisableAutoGenTag: true,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
if all {
|
if all {
|
||||||
RemoveMany(cwhub.PARSERS, "")
|
RemoveMany(cwhub.PARSERS, "")
|
||||||
} else {
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(args) == 0 {
|
||||||
|
log.Fatalf("Specify at least one parser to remove or '--all' flag.")
|
||||||
|
}
|
||||||
|
|
||||||
for _, name := range args {
|
for _, name := range args {
|
||||||
RemoveMany(cwhub.PARSERS, name)
|
RemoveMany(cwhub.PARSERS, name)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
cmdParsersRemove.PersistentFlags().BoolVar(&purge, "purge", false, "Delete source file too")
|
cmdParsersRemove.PersistentFlags().BoolVar(&purge, "purge", false, "Delete source file too")
|
||||||
|
|
|
@ -70,15 +70,19 @@ func NewPostOverflowsCmd() *cobra.Command {
|
||||||
Long: `remove given postoverflow(s)`,
|
Long: `remove given postoverflow(s)`,
|
||||||
Example: `cscli postoverflows remove crowdsec/xxx crowdsec/xyz`,
|
Example: `cscli postoverflows remove crowdsec/xxx crowdsec/xyz`,
|
||||||
DisableAutoGenTag: true,
|
DisableAutoGenTag: true,
|
||||||
Args: cobra.MinimumNArgs(1),
|
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
if all {
|
if all {
|
||||||
RemoveMany(cwhub.PARSERS_OVFLW, "")
|
RemoveMany(cwhub.PARSERS_OVFLW, "")
|
||||||
} else {
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(args) == 0 {
|
||||||
|
log.Fatalf("Specify at least one postoverflow to remove or '--all' flag.")
|
||||||
|
}
|
||||||
|
|
||||||
for _, name := range args {
|
for _, name := range args {
|
||||||
RemoveMany(cwhub.PARSERS_OVFLW, name)
|
RemoveMany(cwhub.PARSERS_OVFLW, name)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
cmdPostOverflowsRemove.PersistentFlags().BoolVar(&purge, "purge", false, "Delete source file too")
|
cmdPostOverflowsRemove.PersistentFlags().BoolVar(&purge, "purge", false, "Delete source file too")
|
||||||
|
|
|
@ -70,16 +70,20 @@ cscli scenarios remove crowdsecurity/ssh-bf
|
||||||
Short: "Remove given scenario(s)",
|
Short: "Remove given scenario(s)",
|
||||||
Long: `remove given scenario(s)`,
|
Long: `remove given scenario(s)`,
|
||||||
Example: `cscli scenarios remove crowdsec/xxx crowdsec/xyz`,
|
Example: `cscli scenarios remove crowdsec/xxx crowdsec/xyz`,
|
||||||
Args: cobra.MinimumNArgs(1),
|
|
||||||
DisableAutoGenTag: true,
|
DisableAutoGenTag: true,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
if all {
|
if all {
|
||||||
RemoveMany(cwhub.SCENARIOS, "")
|
RemoveMany(cwhub.SCENARIOS, "")
|
||||||
} else {
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(args) == 0 {
|
||||||
|
log.Fatalf("Specify at least one scenario to remove or '--all' flag.")
|
||||||
|
}
|
||||||
|
|
||||||
for _, name := range args {
|
for _, name := range args {
|
||||||
RemoveMany(cwhub.SCENARIOS, name)
|
RemoveMany(cwhub.SCENARIOS, name)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
cmdScenariosRemove.PersistentFlags().BoolVar(&purge, "purge", false, "Delete source file too")
|
cmdScenariosRemove.PersistentFlags().BoolVar(&purge, "purge", false, "Delete source file too")
|
||||||
|
|
Loading…
Reference in a new issue