api-base/pkg/args/args.go
2020-08-03 20:19:47 +08:00

29 lines
523 B
Go

package args
import (
"os"
"git.trj.tw/golang/argparse"
)
type Args struct {
ConfigPath string
DBTool bool
Run string
}
var a *Args
func Parse() error {
a = &Args{}
parser := argparse.New()
parser.StringVar(&a.ConfigPath, "", "c", "config", "config file path", nil)
parser.StringVar(&a.Run, "server", "r", "run", "run mode [server, dbtool], default server", nil)
parser.BoolVar(&a.DBTool, false, "d", "dbtool", "run db migration", nil)
parser.Help("h", "help")
return parser.Parse(os.Args)
}