From fdcc60bfd3642207e50e8e6c89c0a9a7b27a40a9 Mon Sep 17 00:00:00 2001
From: Volker Schukai <volker.schukai@schukai.com>
Date: Thu, 23 Nov 2023 00:29:59 +0100
Subject: [PATCH] fix: version result always err 1 #5

---
 source/commandline.go | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/source/commandline.go b/source/commandline.go
index 6acbb62..485847c 100644
--- a/source/commandline.go
+++ b/source/commandline.go
@@ -31,7 +31,7 @@ type commandLineOptions struct {
 	Date struct {
 	} `command:"date" description:"print the current date and time in the format YYYYMMDDHHMMSS"`
 	Auto struct {
-		ExitCode bool `short:"e" long:"exit-code-if-no-bump" description:"exit code to use if no notable changes are found" default:"0"`
+		ExitCode bool `short:"e" long:"exit-code-if-no-bump" description:"exit code to use if no notable changes are found"`
 	} `command:"auto" description:"check the git repository and increase the version if necessary. This implies --git"`
 	Predict struct {
 	} `command:"predict" description:"predict the next version based on the git history. This implies --git"`
@@ -86,6 +86,10 @@ func executeCommand() {
 
 	_, err = p.Parse()
 	if err != nil {
+		if arguments.Verbose {
+			fmt.Printf("Error: %s\n", err)
+		}
+
 		os.Exit(1)
 	}
 
@@ -177,14 +181,23 @@ func executeCommand() {
 		case FixCommit:
 			command = "patch"
 		case OtherCommit:
-			fmt.Println("No notable changes found.")
-			fmt.Println("If you want to force a version\nincrease, use the major, minor\nor patch command.")
 
 			exitCode := 0
+			printMessage := true
 			if arguments.Auto.ExitCode {
+
+				if !arguments.Verbose {
+					printMessage = false
+				}
+
 				exitCode = 1
 			}
 
+			if printMessage {
+				fmt.Println("No notable changes found.")
+				fmt.Println("If you want to force a version\nincrease, use the major, minor\nor patch command.")
+			}
+
 			os.Exit(exitCode)
 		}
 
-- 
GitLab