Skip to content

Commit b16cfbf

Browse files
committed
Tweak help display code
1 parent f0b909a commit b16cfbf

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

v2/app/Kanzi.go

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ func processCommandLine(args []string, argsMap map[string]any) int {
214214
mode := " "
215215
autoBlockSize := false
216216
showHeader := true
217+
showHelp := true
217218

218219
for i, arg := range args {
219220
if i == 0 {
@@ -295,11 +296,18 @@ func processCommandLine(args []string, argsMap map[string]any) int {
295296
}
296297

297298
inputName = strings.TrimSpace(inputName)
299+
} else if arg == "-h" || arg == "--help" {
300+
showHelp = true
298301
}
299302

300303
ctx = -1
301304
}
302305

306+
if showHelp == true || len(args) == 1 {
307+
printHelp(mode, showHeader)
308+
return 0
309+
}
310+
303311
// Overwrite verbosity if the output goes to stdout
304312
if (len(inputName) == 0 && len(outputName) == 0) || strings.EqualFold(outputName, "STDOUT") == true {
305313
verbose = 0
@@ -319,23 +327,13 @@ func processCommandLine(args []string, argsMap map[string]any) int {
319327
warningDupOpt := "Warning: ignoring duplicate %s (%s)"
320328
warningInvalidOpt := "Invalid %s provided on command line: %s"
321329

322-
if len(args) == 1 {
323-
printHelp(mode, showHeader)
324-
return 0
325-
}
326-
327330
for i, arg := range args {
328331
if i == 0 {
329332
continue
330333
}
331334

332335
arg = strings.TrimSpace(arg)
333336

334-
if arg == "--help" || arg == "-h" {
335-
printHelp(mode, showHeader)
336-
return 0
337-
}
338-
339337
if arg == "-c" || arg == "-d" || arg == _ARG_COMPRESS || arg == _ARG_DECOMPRESS {
340338
if ctx != -1 {
341339
log.Println(fmt.Sprintf(warningNoValOpt, _CMD_LINE_ARGS[ctx]), verbose > 0)

0 commit comments

Comments
 (0)