cli: Lookup subcommand names dynamically

This lets us get the chosen subcommands dynamically and removes the
eventual need for three package imports.
This commit is contained in:
James Shubin
2024-03-03 15:48:23 -05:00
parent a65c87b584
commit d537c3d523
3 changed files with 64 additions and 6 deletions

View File

@@ -109,15 +109,15 @@ func (obj *RunArgs) Run(ctx context.Context, data *cliUtil.Data) (bool, error) {
var name string
var args interface{}
if cmd := obj.RunEmpty; cmd != nil {
name = emptyGAPI.Name
name = cliUtil.LookupSubcommand(obj, cmd) // "empty"
args = cmd
}
if cmd := obj.RunLang; cmd != nil {
name = langGAPI.Name
name = cliUtil.LookupSubcommand(obj, cmd) // "lang"
args = cmd
}
if cmd := obj.RunYaml; cmd != nil {
name = yamlGAPI.Name
name = cliUtil.LookupSubcommand(obj, cmd) // "yaml"
args = cmd
}