Remove executable from args in root
This commit is contained in:
parent
def39983fd
commit
31e40ecc82
22
command.go
22
command.go
|
@ -37,21 +37,23 @@ func (c *Command) ApplyOptions(options ...Option) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Command) Execute(args []string) {
|
func (c *Command) Execute(args []string) {
|
||||||
if len(args) == 0 {
|
if c.isRoot {
|
||||||
return
|
args = args[1:]
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, subcommand := range c.Subcommands {
|
if len(args) > 0 {
|
||||||
if subcommand.Name == args[0] {
|
for _, subcommand := range c.Subcommands {
|
||||||
subcommand.Execute(args[1:])
|
if subcommand.Name == args[0] {
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, alias := range subcommand.Aliases {
|
|
||||||
if alias == args[0] {
|
|
||||||
subcommand.Execute(args[1:])
|
subcommand.Execute(args[1:])
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, alias := range subcommand.Aliases {
|
||||||
|
if alias == args[0] {
|
||||||
|
subcommand.Execute(args[1:])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,4 +2,4 @@ module go.fifitido.net/cmd/examples/hello-world
|
||||||
|
|
||||||
go 1.21.3
|
go 1.21.3
|
||||||
|
|
||||||
require go.fifitido.net/cmd v0.0.0-20231110043437-c32ce2efcd5f
|
require go.fifitido.net/cmd v0.0.0-20231110054944-def39983fdfa
|
||||||
|
|
|
@ -1,2 +1,4 @@
|
||||||
go.fifitido.net/cmd v0.0.0-20231110043437-c32ce2efcd5f h1:v+sjO+t6cGEtDhStOnuypYBrkOMO4suiDVxL93rOUCs=
|
go.fifitido.net/cmd v0.0.0-20231110043437-c32ce2efcd5f h1:v+sjO+t6cGEtDhStOnuypYBrkOMO4suiDVxL93rOUCs=
|
||||||
go.fifitido.net/cmd v0.0.0-20231110043437-c32ce2efcd5f/go.mod h1:8SaDxCG1m6WwShUlZApSbNleCvV7oTfqZIyYu4aAqO0=
|
go.fifitido.net/cmd v0.0.0-20231110043437-c32ce2efcd5f/go.mod h1:8SaDxCG1m6WwShUlZApSbNleCvV7oTfqZIyYu4aAqO0=
|
||||||
|
go.fifitido.net/cmd v0.0.0-20231110054944-def39983fdfa h1:Z62sZG2rnKMqa0jI+WD1t8vO9ESQsQa4j6ad9OFeREM=
|
||||||
|
go.fifitido.net/cmd v0.0.0-20231110054944-def39983fdfa/go.mod h1:8SaDxCG1m6WwShUlZApSbNleCvV7oTfqZIyYu4aAqO0=
|
||||||
|
|
Loading…
Reference in New Issue