First commit

This commit is contained in:
2022-01-13 23:27:39 +01:00
parent dab6549cad
commit f53bf1b804
93 changed files with 11042 additions and 0 deletions

48
pkg/obioptions/options.go Normal file
View 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
}