Skip to content

Commit

Permalink
Adding --all flag to output all the things
Browse files Browse the repository at this point in the history
Signed-off-by: Mikkel Mørk Hegnhøj <[email protected]>
  • Loading branch information
mikkelhegn committed Aug 30, 2024
1 parent ff2a699 commit 97d066d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ var All bool
func init() {
showCmd.PersistentFlags().StringP("file", "f", "", "Specifies the path to the spin.toml file you wish to visualize")
showCmd.PersistentFlags().StringP("env", "e", "", "Specifies the path to the \".env\" file containing your Spin variables")
showCmd.PersistentFlags().BoolVarP(&All, "all", "a", false, "Output information about all component. Only applies if no component name is specified.")
showCmd.PersistentFlags().BoolVarP(&All, "all", "a", false, "Output information about all component. Only applies if no component name is specified.")
rootCmd.AddCommand(showCmd)
}
14 changes: 7 additions & 7 deletions cmd/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var showCmd = &cobra.Command{
Long: `The "show" command reads a spin.toml file and prints a table of components to the terminal.
You can optionally specify a component to display information for a specific component only.
By default, the command looks for a "spin.toml" file in the current directory.`,
Args: cobra.MaximumNArgs(2),
Args: cobra.MaximumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
// The path to a "spin.toml" file
path, err := cmd.Flags().GetString("file")
Expand Down Expand Up @@ -59,12 +59,12 @@ By default, the command looks for a "spin.toml" file in the current directory.`,
// This won't throw errors because we are not checking the validity of a "spin.toml" file
fmt.Print(showAllComponents(tomlData, envVars))

// Also print info about all components if --all flag is set
if All {
for name, _ := range tomlData.Component {
fmt.Print(showSpecificComponent(tomlData, envVars, name))
}
}
// Also print info about all components if --all flag is set
if All {
for name, _ := range tomlData.Component {
fmt.Print(showSpecificComponent(tomlData, envVars, name))
}
}

} else {
terminalOutput, err := showSpecificComponent(tomlData, envVars, args[0])
Expand Down

0 comments on commit 97d066d

Please sign in to comment.