29 lines
495 B
Go
29 lines
495 B
Go
|
package options
|
||
|
|
||
|
import "flag"
|
||
|
|
||
|
// Options -
|
||
|
type Options struct {
|
||
|
Help bool
|
||
|
Config string
|
||
|
}
|
||
|
|
||
|
var opts *Options
|
||
|
|
||
|
// GetOptions -
|
||
|
func GetOptions() *Options { return opts }
|
||
|
|
||
|
// RegOptions -
|
||
|
func RegOptions() {
|
||
|
opts = &Options{}
|
||
|
flag.StringVar(&opts.Config, "config", "", "config file path")
|
||
|
flag.StringVar(&opts.Config, "f", "", "config file path (short)")
|
||
|
flag.BoolVar(&opts.Help, "h", false, "show usage")
|
||
|
flag.Parse()
|
||
|
}
|
||
|
|
||
|
// ShowUsage -
|
||
|
func (p *Options) ShowUsage() {
|
||
|
flag.Usage()
|
||
|
}
|