Skip to content

Commit e623b06

Browse files
committed
feat(command/list): improve output of resources
1 parent abbe053 commit e623b06

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

pkg/commands/list/list.go

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
package list
22

33
import (
4-
"strings"
5-
64
"github.com/fatih/color"
75
"github.com/urfave/cli/v2"
6+
"slices"
7+
"strings"
88

99
"github.com/ekristen/aws-nuke/v3/pkg/commands/global"
1010
"github.com/ekristen/aws-nuke/v3/pkg/common"
1111

12-
_ "github.com/ekristen/aws-nuke/v3/resources"
1312
"github.com/ekristen/libnuke/pkg/registry"
13+
14+
_ "github.com/ekristen/aws-nuke/v3/resources"
1415
)
1516

1617
func execute(c *cli.Context) error {
@@ -21,19 +22,26 @@ func execute(c *cli.Context) error {
2122
ls = registry.GetNames()
2223
}
2324

25+
slices.Sort(ls)
26+
2427
for _, name := range ls {
25-
if strings.HasPrefix(name, "AWS::") {
28+
reg := registry.GetRegistration(name)
29+
30+
if reg == nil {
2631
continue
2732
}
2833

29-
reg := registry.GetRegistration(name)
30-
3134
if reg.AlternativeResource != "" {
32-
color.New(color.Bold).Printf("%-55s\n", name)
35+
color.New(color.Bold).Printf("%-59s", name)
36+
color.New(color.FgCyan).Printf("native resource\n")
3337
color.New(color.Bold, color.FgYellow).Printf(" > %-55s", reg.AlternativeResource)
34-
color.New(color.FgCyan).Printf("alternative cloud-control resource\n")
38+
color.New(color.FgHiBlue).Printf("alternative cloud-control resource\n")
39+
} else if strings.HasPrefix(reg.Name, "AWS::") {
40+
color.New(color.Bold).Printf("%-59s", name)
41+
color.New(color.FgHiMagenta).Printf("cloud-control resource\n")
3542
} else {
36-
color.New(color.Bold).Printf("%-55s\n", name)
43+
color.New(color.Bold).Printf("%-59s", name)
44+
color.New(color.FgCyan).Printf("native resource\n")
3745
}
3846
}
3947

0 commit comments

Comments
 (0)