diff --git a/src/cmd/check.go b/src/cmd/check.go index 1cd39ae..fe080e7 100644 --- a/src/cmd/check.go +++ b/src/cmd/check.go @@ -23,7 +23,7 @@ import ( "github.com/spf13/cobra" ) -var boolOutput bool +var checkBoolOutput bool // checkCmd represents the check command var checkCmd = &cobra.Command{ @@ -50,14 +50,14 @@ var checkCmd = &cobra.Command{ return err } if tagExists { - if boolOutput { + if checkBoolOutput { fmt.Println("false") } else { fmt.Printf("Version %s is already tagged\n", versionAndFlavor) return errors.New("no release necessary") } } else { - if boolOutput { + if checkBoolOutput { fmt.Println("true") } else { fmt.Printf("Version %s is not tagged\n", versionAndFlavor) @@ -68,6 +68,6 @@ var checkCmd = &cobra.Command{ } func init() { - checkCmd.Flags().BoolVarP(&boolOutput, "boolean", "b", false, "Switch the output string to a true/false based on if a release is necessary. True if a release is necessary, false if not.") + checkCmd.Flags().BoolVarP(&checkBoolOutput, "boolean", "b", false, "Switch the output string to a true/false based on if a release is necessary. True if a release is necessary, false if not.") rootCmd.AddCommand(checkCmd) } diff --git a/src/cmd/show.go b/src/cmd/show.go index 08dbae7..5a36e50 100644 --- a/src/cmd/show.go +++ b/src/cmd/show.go @@ -22,6 +22,8 @@ import ( "github.com/spf13/cobra" ) +var showVersionOnly bool + // showCmd represents the show command var showCmd = &cobra.Command{ Use: "show flavor", @@ -40,7 +42,11 @@ var showCmd = &cobra.Command{ rootCmd.SilenceUsage = true - fmt.Printf("%s-%s\n", currentFlavor.Version, currentFlavor.Name) + if showVersionOnly { + fmt.Printf("%s\n", currentFlavor.Version) + } else { + fmt.Printf("%s-%s\n", currentFlavor.Version, currentFlavor.Name) + } return nil }, @@ -48,4 +54,5 @@ var showCmd = &cobra.Command{ func init() { rootCmd.AddCommand(showCmd) + showCmd.Flags().BoolVarP(&showVersionOnly, "version-only", "v", false, "Show only the version without flavor appended") } diff --git a/src/test/e2e/00_show_test.go b/src/test/e2e/00_show_test.go index 9baf6cb..c6e9152 100644 --- a/src/test/e2e/00_show_test.go +++ b/src/test/e2e/00_show_test.go @@ -12,3 +12,10 @@ func TestShowCommand(t *testing.T) { require.Equal(t, "1.0.0-uds.0-base\n", stdout) } + +func TestShowCommandVersionFlag(t *testing.T) { + stdout, stderr, err := e2e.UDSReleaserDir("src/test", "show", "base", "--version-only") + require.NoError(t, err, stdout, stderr) + + require.Equal(t, "1.0.0-uds.0\n", stdout) +} diff --git a/tasks.yaml b/tasks.yaml index 9fa089b..ac194d6 100644 --- a/tasks.yaml +++ b/tasks.yaml @@ -12,9 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -includes: - - test: tasks/tests.yaml - tasks: # build tasks - name: build-all