mirror of
https://github.com/crowdsecurity/crowdsec.git
synced 2025-05-16 22:40:54 +02:00
* unexport subcommand constructors * unexport internal methods * lint + rename local variables
31 lines
685 B
Go
31 lines
685 B
Go
package clihubtest
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
func (cli *cliHubTest) newCleanCmd() *cobra.Command {
|
|
cmd := &cobra.Command{
|
|
Use: "clean",
|
|
Short: "clean [test_name]",
|
|
Args: cobra.MinimumNArgs(1),
|
|
DisableAutoGenTag: true,
|
|
RunE: func(_ *cobra.Command, args []string) error {
|
|
for _, testName := range args {
|
|
test, err := hubPtr.LoadTestItem(testName)
|
|
if err != nil {
|
|
return fmt.Errorf("unable to load test '%s': %w", testName, err)
|
|
}
|
|
if err := test.Clean(); err != nil {
|
|
return fmt.Errorf("unable to clean test '%s' env: %w", test.Name, err)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
},
|
|
}
|
|
|
|
return cmd
|
|
}
|