diff --git a/entry/entry.go b/entry/entry.go index c2eef116..33a0bef9 100644 --- a/entry/entry.go +++ b/entry/entry.go @@ -170,6 +170,12 @@ type Runner struct { data *Data } +// Name returns the name of the program, which should match the argv[1] of what +// we want to use to call this from the top-level main. +func (obj *Runner) Name() string { + return obj.data.Program +} + // CLI is the entry point for using any embedded package from the CLI. It is // used as the main entry point from the top-level main function and kicks-off // the CLI parser. diff --git a/main.go b/main.go index 71483dee..09c4ab98 100644 --- a/main.go +++ b/main.go @@ -90,7 +90,8 @@ func main() { } // is there an alternate entry point for the cli? - if cli, err := entry.Lookup(); err == nil { + if cli, err := entry.Lookup(); err == nil && len(data.Args) > 1 && cli.Name() == data.Args[1] { + data.Args = data.Args[1:] // pop off "argv[0]" if err := cli.CLI(context.Background(), data); err != nil { fmt.Println(err) os.Exit(1)