matejak / argbash

Bash argument parsing code generator
Other
1.4k stars 62 forks source link

feature request: help and completion for TYPE_GROUP_SET #81

Open hemna opened 5 years ago

hemna commented 5 years ago

I have an script that has a list of string values that are acceptable as a command.

# ARG_POSITIONAL_SINGLE([command], [The command you want to run.], [setup_everything])
# ARG_TYPE_GROUP_SET([commands], [COMMAND], [command], [add_compute,build_images,deploy_airship,deploy_osh,clean_airship,clean_airship_not_images,clean_k8s,deploy_caasp,deploy_ccp_deployer,deploy_ses,enroll_caasp_workers,patch_upstream,setup_airship,setup_caasp_workers_for_openstack,setup_everything,setup_hosts,setup_openstack,teardown,update_airship_osh], [index])

It would be nice if the help output included the list of possible values for that specific command. Currently, this is all you get...

    <command>: The command you want to run. (default: 'setup_everything')

You can't find out what the possible values are unless you give the generated script a bogus value.

Also, The bash completion doesn't support showing those list when you try tab for the command.

matejak commented 5 years ago

The bash completion that is not working is a bug, it is expected to work.

The help message request is a duplicate of #76.

matejak commented 5 years ago

So the completion now works only for optional arguments, positional arguments (s.a. your example) don't have the completion implemented. This is not trivial, as the completion functionality would generally have to understand what argument is being completed. This is easy for optional args (it is enough just to look at the previous word on the command-line), but it is more complicated for positional arguments - is it the first one, second one, ...?