-
Notifications
You must be signed in to change notification settings - Fork 5
/
add.go
38 lines (32 loc) · 1.1 KB
/
add.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package cmd
import (
"time"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/c4t-but-s4d/neo/v2/cmd/client/cli"
"github.com/c4t-but-s4d/neo/v2/internal/client"
)
// addCmd represents the add command
var addCmd = &cobra.Command{
Use: "add",
Short: "Add an exploit",
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
cfg := client.MustUnmarshalConfig()
cli := cli.NewAdd(cmd, args, cfg)
ctx := cmd.Context()
if err := cli.Run(ctx); err != nil {
logrus.Fatalf("Error adding exploit: %v", err)
}
logrus.Debugf("Add finished")
},
}
func init() {
rootCmd.AddCommand(addCmd)
addCmd.PersistentFlags().String("id", "", "exploit name")
addCmd.PersistentFlags().BoolP("dir", "d", false, "add exploit as a directory")
addCmd.PersistentFlags().DurationP("interval", "i", time.Second*30, "run interval")
addCmd.PersistentFlags().DurationP("timeout", "t", time.Second*30, "timeout for a single run")
addCmd.PersistentFlags().BoolP("endless", "e", false, "mark exploit as endless")
addCmd.PersistentFlags().Bool("disabled", false, "mark exploit as disabled")
}