-
Notifications
You must be signed in to change notification settings - Fork 208
/
show_cmd.go
36 lines (33 loc) · 972 Bytes
/
show_cmd.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
package main
import (
"errors"
"fmt"
"github.com/datadog/stratus-red-team/v2/pkg/stratus"
"github.com/spf13/cobra"
)
func buildShowCmd() *cobra.Command {
warmupCmd := &cobra.Command{
Use: "show",
Short: "Displays detailed information about an attack technique.",
Args: func(cmd *cobra.Command, args []string) error {
if len(args) == 0 {
return errors.New("you must specify at least one attack technique")
}
_, err := resolveTechniques(args)
return err
},
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return getTechniquesCompletion(toComplete), cobra.ShellCompDirectiveNoFileComp
},
Run: func(cmd *cobra.Command, args []string) {
techniques, _ := resolveTechniques(args)
doShowCmd(techniques)
},
}
return warmupCmd
}
func doShowCmd(techniques []*stratus.AttackTechnique) {
for i := range techniques {
fmt.Println(techniques[i].Description)
}
}