@@ -214,6 +214,7 @@ func processCommandLine(args []string, argsMap map[string]any) int {
214
214
mode := " "
215
215
autoBlockSize := false
216
216
showHeader := true
217
+ showHelp := true
217
218
218
219
for i , arg := range args {
219
220
if i == 0 {
@@ -295,11 +296,18 @@ func processCommandLine(args []string, argsMap map[string]any) int {
295
296
}
296
297
297
298
inputName = strings .TrimSpace (inputName )
299
+ } else if arg == "-h" || arg == "--help" {
300
+ showHelp = true
298
301
}
299
302
300
303
ctx = - 1
301
304
}
302
305
306
+ if showHelp == true || len (args ) == 1 {
307
+ printHelp (mode , showHeader )
308
+ return 0
309
+ }
310
+
303
311
// Overwrite verbosity if the output goes to stdout
304
312
if (len (inputName ) == 0 && len (outputName ) == 0 ) || strings .EqualFold (outputName , "STDOUT" ) == true {
305
313
verbose = 0
@@ -319,23 +327,13 @@ func processCommandLine(args []string, argsMap map[string]any) int {
319
327
warningDupOpt := "Warning: ignoring duplicate %s (%s)"
320
328
warningInvalidOpt := "Invalid %s provided on command line: %s"
321
329
322
- if len (args ) == 1 {
323
- printHelp (mode , showHeader )
324
- return 0
325
- }
326
-
327
330
for i , arg := range args {
328
331
if i == 0 {
329
332
continue
330
333
}
331
334
332
335
arg = strings .TrimSpace (arg )
333
336
334
- if arg == "--help" || arg == "-h" {
335
- printHelp (mode , showHeader )
336
- return 0
337
- }
338
-
339
337
if arg == "-c" || arg == "-d" || arg == _ARG_COMPRESS || arg == _ARG_DECOMPRESS {
340
338
if ctx != - 1 {
341
339
log .Println (fmt .Sprintf (warningNoValOpt , _CMD_LINE_ARGS [ctx ]), verbose > 0 )
0 commit comments