Skip to content

Commit

Permalink
update describe command
Browse files Browse the repository at this point in the history
  • Loading branch information
Cerebrovinny committed Feb 1, 2025
1 parent b9f5026 commit ae9770a
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 154 deletions.
28 changes: 17 additions & 11 deletions cmd/list_stacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (

e "github.com/cloudposse/atmos/internal/exec"
"github.com/cloudposse/atmos/pkg/config"
l "github.com/cloudposse/atmos/pkg/list"
"github.com/cloudposse/atmos/pkg/schema"
"github.com/cloudposse/atmos/pkg/ui/theme"
u "github.com/cloudposse/atmos/pkg/utils"
Expand All @@ -16,20 +15,18 @@ import (
// listStacksCmd lists atmos stacks
var listStacksCmd = &cobra.Command{
Use: "stacks",
Short: "List all Atmos stacks or stacks for a specific component",
Long: "This command lists all Atmos stacks, or filters the list to show only the stacks associated with a specified component.",
Short: "List all Atmos stacks",
Long: "This command lists all Atmos stacks. For detailed filtering and output formatting, use 'atmos describe stacks'.",
Example: "# List all stacks\n" +
"atmos list stacks\n\n" +
"# List stacks for a specific component\n" +
"atmos list stacks -c <component>",
"# For detailed stack information and filtering, use:\n" +
"atmos describe stacks",
FParseErrWhitelist: struct{ UnknownFlags bool }{UnknownFlags: false},
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) {
// Check Atmos configuration
checkAtmosConfig()

componentFlag, _ := cmd.Flags().GetString("component")

configAndStacksInfo := schema.ConfigAndStacksInfo{}
atmosConfig, err := config.InitCliConfig(configAndStacksInfo, true)
if err != nil {
Expand All @@ -43,17 +40,26 @@ var listStacksCmd = &cobra.Command{
return
}

output, err := l.FilterAndListStacks(stacksMap, componentFlag, "", "", "")
if err != nil {
u.PrintMessageInColor(fmt.Sprintf("Error filtering stacks: %v", err), theme.Colors.Error)
// Simple list of stack names
var stackNames []string
for stackName := range stacksMap {
stackNames = append(stackNames, stackName)
}

if len(stackNames) == 0 {
u.PrintMessageInColor("No stacks found\n", theme.Colors.Warning)
return
}

output := "Available stacks:\n"
for _, name := range stackNames {
output += fmt.Sprintf(" %s\n", name)
}
u.PrintMessageInColor(output, theme.Colors.Success)
},
}

func init() {
listStacksCmd.DisableFlagParsing = false
listStacksCmd.PersistentFlags().StringP("component", "c", "", "Filter stacks by component")
listCmd.AddCommand(listStacksCmd)
}
112 changes: 0 additions & 112 deletions pkg/list/list_stacks.go

This file was deleted.

7 changes: 0 additions & 7 deletions tests/snapshots/TestCLICommands_atmos_--help.stdout.golden

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ae9770a

Please sign in to comment.