From 97d066dc44d5ab394e75789e1d87ced83d826f00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikkel=20M=C3=B8rk=20Hegnh=C3=B8j?= Date: Fri, 30 Aug 2024 16:23:42 +0200 Subject: [PATCH] Adding --all flag to output all the things MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mikkel Mørk Hegnhøj --- cmd/root.go | 2 +- cmd/show.go | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index c50bddf..12a4df0 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -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) } diff --git a/cmd/show.go b/cmd/show.go index 8a5896b..2ac3ca3 100644 --- a/cmd/show.go +++ b/cmd/show.go @@ -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") @@ -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])