mirror of
https://github.com/rwxrob/bonzai
synced 2024-11-18 15:25:45 +00:00
Add Cmd.UsageError
This commit is contained in:
parent
107a091650
commit
3468bffaf0
8
cmd.go
8
cmd.go
@ -87,7 +87,7 @@ func (x *Cmd) Run() {
|
||||
// seek should never fail to return something, but ...
|
||||
cmd, args := x.Seek(os.Args[1:])
|
||||
if cmd == nil {
|
||||
ExitError("usage: %v %v\n", x.Name, x.Usage)
|
||||
ExitError(x.UsageError())
|
||||
}
|
||||
|
||||
// default to first Command if no Call defined
|
||||
@ -102,7 +102,7 @@ func (x *Cmd) Run() {
|
||||
}
|
||||
Exit()
|
||||
}
|
||||
ExitError("usage: %v %v\n", x.Name, x.Usage)
|
||||
ExitError(x.UsageError())
|
||||
}
|
||||
|
||||
// delegate
|
||||
@ -112,6 +112,10 @@ func (x *Cmd) Run() {
|
||||
Exit()
|
||||
}
|
||||
|
||||
func (x *Cmd) UsageError() error {
|
||||
return fmt.Sprintf("usage: %v %v\n", x.Name, x.Usage)
|
||||
}
|
||||
|
||||
// Add creates a new Cmd and sets the name and aliases and adds to
|
||||
// Commands returning a reference to the new Cmd. The name must be
|
||||
// first.
|
||||
|
Loading…
Reference in New Issue
Block a user