Skip to content

Commit 4b77cc0

Browse files
leogrpoiana
authored andcommitted
update(cmd): add --all flag for list command
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
1 parent 8ee0074 commit 4b77cc0

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

cmd/list.go

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,16 @@ func NewList() *cobra.Command {
3838
DisableAutoGenTag: true,
3939
}
4040

41+
flags := c.Flags()
42+
flags.Bool("all", false, "List all actions, including those disabled by default")
43+
4144
c.RunE = func(c *cobra.Command, args []string) error {
4245

46+
all, err := flags.GetBool("all")
47+
if err != nil {
48+
return err
49+
}
50+
4351
var evts map[string]events.Action
4452
if len(args) == 0 {
4553
evts = events.All()
@@ -54,15 +62,20 @@ func NewList() *cobra.Command {
5462
if len(evts) == 0 {
5563
return fmt.Errorf(`no events matching '%s'`, args[0])
5664
}
57-
5865
}
5966

60-
actions := make([]string, len(evts))
61-
i := 0
67+
var actions []string
6268
for action := range evts {
63-
actions[i] = action
64-
i++
69+
if !all && events.Disabled(action) {
70+
continue
71+
}
72+
actions = append(actions, action)
73+
}
74+
75+
if len(actions) == 0 {
76+
return fmt.Errorf(`no enabled events matching '%s'`, args[0])
6577
}
78+
6679
sort.Strings(actions)
6780

6881
for _, v := range actions {

0 commit comments

Comments
 (0)