Skip to content

Commit 93bd050

Browse files
committed
Fixed empty sub commands logic structure
1 parent 7500184 commit 93bd050

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

command.go

+1
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ func (cmd *Command) CheckSubCommand(subcmd string) (*Command, error) {
112112

113113
var (
114114
ErrNoASubCommand = errors.New("invalid command format")
115+
ErrNoSubCommands = errors.New("no subcommands to look through")
115116
)
116117

117118
// Checks user input looking for sub commands until the last one is found

rhombifer.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,13 @@ func ExecCommand(cmd string, args ...string) error {
8080
}
8181

8282
childcommand, args, err := DigThroughSubCommand(subcommand.Subs, args)
83-
if err != nil {
83+
if err != nil && err != ErrNoSubCommands {
8484
return err
8585
}
8686

87-
subcommand = childcommand
87+
if childcommand != nil {
88+
subcommand = childcommand
89+
}
8890

8991
if subcommand.Run == nil {
9092
return fmt.Errorf("Sub command %s, does not have a valid function (Run)", subcommand.Name)

0 commit comments

Comments
 (0)