mirror of
https://github.com/metabarcoding/obitools4.git
synced 2025-06-29 16:20:46 +00:00
First commit
This commit is contained in:
48
pkg/obioptions/options.go
Normal file
48
pkg/obioptions/options.go
Normal file
@ -0,0 +1,48 @@
|
||||
package obioptions
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/DavidGamba/go-getoptions"
|
||||
)
|
||||
|
||||
var __debug__ = false
|
||||
var __profiling__ = ""
|
||||
|
||||
type ArgumentParser func([]string) (*getoptions.GetOpt, []string, error)
|
||||
|
||||
func GenerateOptionParser(optionset ...func(*getoptions.GetOpt)) ArgumentParser {
|
||||
options := getoptions.New()
|
||||
options.Bool("help", false, options.Alias("h", "?"))
|
||||
options.BoolVar(&__debug__, "debug", false)
|
||||
// options.StringVar(&__profiling__, "profile", "")
|
||||
|
||||
for _, o := range optionset {
|
||||
o(options)
|
||||
}
|
||||
|
||||
return func(args []string) (*getoptions.GetOpt, []string, error) {
|
||||
|
||||
remaining, err := options.Parse(args[1:])
|
||||
|
||||
if options.Called("help") {
|
||||
fmt.Fprintf(os.Stderr, options.Help())
|
||||
os.Exit(1)
|
||||
}
|
||||
return options, remaining, err
|
||||
}
|
||||
}
|
||||
|
||||
// Predicate indicating if the debug mode is activated
|
||||
func IsDebugMode() bool {
|
||||
return __debug__
|
||||
}
|
||||
|
||||
func DebugOn() {
|
||||
__debug__ = true
|
||||
}
|
||||
|
||||
func DebugOff() {
|
||||
__debug__ = false
|
||||
}
|
Reference in New Issue
Block a user