Skip to content

Commit

Permalink
feat(command/list): improve output of resources
Browse files Browse the repository at this point in the history
  • Loading branch information
ekristen committed Jan 10, 2025
1 parent abbe053 commit e623b06
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions pkg/commands/list/list.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
package list

import (
"strings"

"github.com/fatih/color"
"github.com/urfave/cli/v2"
"slices"
"strings"

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

_ "github.com/ekristen/aws-nuke/v3/resources"
"github.com/ekristen/libnuke/pkg/registry"

_ "github.com/ekristen/aws-nuke/v3/resources"
)

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

slices.Sort(ls)

for _, name := range ls {
if strings.HasPrefix(name, "AWS::") {
reg := registry.GetRegistration(name)

if reg == nil {
continue
}

reg := registry.GetRegistration(name)

if reg.AlternativeResource != "" {
color.New(color.Bold).Printf("%-55s\n", name)
color.New(color.Bold).Printf("%-59s", name)
color.New(color.FgCyan).Printf("native resource\n")
color.New(color.Bold, color.FgYellow).Printf(" > %-55s", reg.AlternativeResource)
color.New(color.FgCyan).Printf("alternative cloud-control resource\n")
color.New(color.FgHiBlue).Printf("alternative cloud-control resource\n")
} else if strings.HasPrefix(reg.Name, "AWS::") {
color.New(color.Bold).Printf("%-59s", name)
color.New(color.FgHiMagenta).Printf("cloud-control resource\n")
} else {
color.New(color.Bold).Printf("%-55s\n", name)
color.New(color.Bold).Printf("%-59s", name)
color.New(color.FgCyan).Printf("native resource\n")
}
}

Expand Down

0 comments on commit e623b06

Please sign in to comment.