add routes, config, args pkg

This commit is contained in:
Jay
2020-08-03 20:19:47 +08:00
commit f92efa91fc
6 changed files with 261 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
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)
}