mirror of
https://github.com/metabarcoding/obitools4.git
synced 2025-06-29 16:20:46 +00:00
Make the --help
or -h
options working when mandatory options are declared
Former-commit-id: db502ff81dcf20449d126978fcebf890edb814ae
This commit is contained in:
@ -41,8 +41,22 @@ func GenerateOptionParser(optionset ...func(*getoptions.GetOpt)) ArgumentParser
|
||||
|
||||
remaining, err := options.Parse(args[1:])
|
||||
|
||||
if options.Called("help") {
|
||||
fmt.Fprint(os.Stderr, options.Help())
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
log.SetLevel(log.InfoLevel)
|
||||
if options.Called("debug") {
|
||||
log.SetLevel(log.DebugLevel)
|
||||
log.Debugln("Switch to debug level logging")
|
||||
}
|
||||
|
||||
// Handle user errors
|
||||
if err != nil {
|
||||
log.Fatalf("Error on the commande line : %v",err)
|
||||
fmt.Fprintf(os.Stderr, "ERROR: %s\n\n", err)
|
||||
fmt.Fprint(os.Stderr, options.Help(getoptions.HelpSynopsis))
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// Setup the maximum number of CPU usable by the program
|
||||
@ -59,17 +73,6 @@ func GenerateOptionParser(optionset ...func(*getoptions.GetOpt)) ArgumentParser
|
||||
log.Printf("No singleton option set")
|
||||
}
|
||||
|
||||
if options.Called("help") {
|
||||
fmt.Fprint(os.Stderr, options.Help())
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
log.SetLevel(log.InfoLevel)
|
||||
if options.Called("debug") {
|
||||
log.SetLevel(log.DebugLevel)
|
||||
log.Debugln("Switch to debug level logging")
|
||||
}
|
||||
|
||||
return options, remaining
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user