mirror of
https://github.com/rwxrob/bonzai
synced 2024-11-14 18:12:59 +00:00
Fix bug with default command
This commit is contained in:
parent
46311d593c
commit
0ed264ef76
14
cmd.go
14
cmd.go
@ -95,9 +95,6 @@ func (x *Cmd) Run() {
|
||||
Exit()
|
||||
}
|
||||
|
||||
x.Root = x
|
||||
x.Conf = DefaultConfigurer
|
||||
|
||||
// seek should never fail to return something, but ...
|
||||
cmd, args := x.Seek(os.Args[1:])
|
||||
if cmd == nil {
|
||||
@ -108,8 +105,7 @@ func (x *Cmd) Run() {
|
||||
if cmd.Call == nil {
|
||||
if len(cmd.Commands) > 0 {
|
||||
os.Args = append(os.Args, cmd.Commands[0].Name)
|
||||
cmd.Commands[0].Caller = cmd
|
||||
cmd.Commands[0].Run()
|
||||
x.Run()
|
||||
return
|
||||
} else {
|
||||
ExitError(x.Unimplemented())
|
||||
@ -133,6 +129,12 @@ func (x *Cmd) Unimplemented() error {
|
||||
return fmt.Errorf("%q has not yet been implemented", x.Name)
|
||||
}
|
||||
|
||||
// MissingConfig returns an error showing the expected configuration
|
||||
// entry that is missing from the given path.
|
||||
func (x *Cmd) MissingConfig(path string) error {
|
||||
return fmt.Errorf("missing config: %v", x.Branch()+"."+path)
|
||||
}
|
||||
|
||||
// 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.
|
||||
@ -204,6 +206,8 @@ func (x *Cmd) Seek(args []string) (*Cmd, []string) {
|
||||
return x, args
|
||||
}
|
||||
cur := x
|
||||
cur.Root = x
|
||||
cur.Conf = DefaultConfigurer
|
||||
n := 0
|
||||
for ; n < len(args); n++ {
|
||||
next := cur.Cmd(args[n])
|
||||
|
Loading…
Reference in New Issue
Block a user