Skip to content

Commit

Permalink
Tweak help display code
Browse files Browse the repository at this point in the history
  • Loading branch information
flanglet committed May 12, 2024
1 parent f0b909a commit b16cfbf
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions v2/app/Kanzi.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ func processCommandLine(args []string, argsMap map[string]any) int {
mode := " "
autoBlockSize := false
showHeader := true
showHelp := true

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

inputName = strings.TrimSpace(inputName)
} else if arg == "-h" || arg == "--help" {
showHelp = true
}

ctx = -1
}

if showHelp == true || len(args) == 1 {
printHelp(mode, showHeader)
return 0
}

// Overwrite verbosity if the output goes to stdout
if (len(inputName) == 0 && len(outputName) == 0) || strings.EqualFold(outputName, "STDOUT") == true {
verbose = 0
Expand All @@ -319,23 +327,13 @@ func processCommandLine(args []string, argsMap map[string]any) int {
warningDupOpt := "Warning: ignoring duplicate %s (%s)"
warningInvalidOpt := "Invalid %s provided on command line: %s"

if len(args) == 1 {
printHelp(mode, showHeader)
return 0
}

for i, arg := range args {
if i == 0 {
continue
}

arg = strings.TrimSpace(arg)

if arg == "--help" || arg == "-h" {
printHelp(mode, showHeader)
return 0
}

if arg == "-c" || arg == "-d" || arg == _ARG_COMPRESS || arg == _ARG_DECOMPRESS {
if ctx != -1 {
log.Println(fmt.Sprintf(warningNoValOpt, _CMD_LINE_ARGS[ctx]), verbose > 0)
Expand Down

0 comments on commit b16cfbf

Please sign in to comment.