...
This commit is contained in:
parent
c382bc403f
commit
3199e25c38
1 changed files with 13 additions and 3 deletions
|
@ -10,6 +10,8 @@ import(
|
|||
|
||||
type Flags struct {
|
||||
*flag.FlagSet
|
||||
progName string
|
||||
utilName string
|
||||
args []string
|
||||
parsedArgs []string
|
||||
}
|
||||
|
@ -32,6 +34,14 @@ func (flags *Flags) Args() []string {
|
|||
return flags.parsedArgs
|
||||
}
|
||||
|
||||
func (flags *Flags) ProgName() string {
|
||||
return flags.progName
|
||||
}
|
||||
|
||||
func (flags *Flags) UtilName() string {
|
||||
return flags.utilName
|
||||
}
|
||||
|
||||
func Main(name string, m Tools) {
|
||||
var(
|
||||
utilName string
|
||||
|
@ -75,9 +85,7 @@ func Main(name string, m Tools) {
|
|||
arg1 := os.Args[1]
|
||||
flagSet := flag.NewFlagSet(arg1, flag.ExitOnError)
|
||||
flags := &Flags{
|
||||
flagSet,
|
||||
[]string{},
|
||||
[]string{},
|
||||
FlagSet : flagSet,
|
||||
}
|
||||
flags.Usage = func() {
|
||||
out := flags.Output()
|
||||
|
@ -115,6 +123,8 @@ func Main(name string, m Tools) {
|
|||
os.Exit(1)
|
||||
}
|
||||
|
||||
flags.progName = name
|
||||
flags.utilName = args[0]
|
||||
flags.args = args[1:]
|
||||
|
||||
util.Handler(flags)
|
||||
|
|
Loading…
Reference in a new issue