Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Specifiying global option immediately after console name prevents specific long options for arguments from completing #83

Closed
danemacmillan opened this issue Feb 21, 2018 · 1 comment
Labels

Comments

@danemacmillan
Copy link

My console tool has several global options, such as the defaults like --ansi or --help, and some of my custom arguments have their own specific options that are only available to them.

I've noticed that if I specify a global option immediately after the console tool name, linus in this case, and then attempt to get tab completion for an option against the argument name that follows, the completion suggestions only include the global ones, and ignore the specific ones specific to the argument name. However, if I move the global option after the argument name, I get tab completion for all possible options, both global, and more importantly, the specific ones that are available to the argument name.

See the following output as an example of the difference between the completion suggestions when a global option is passed immediately after the console tool name, and then when a global option is passed immediately after the argument name:

danemacmillan@macmillanator.local ~ $ linus -v deploy:update --
--ansi                    --load-config             --no-cleanup              --quiet                   --save-config-all         --verbose
--help                    --no-ansi                 --no-interaction          --save-config             --save-config-before-run  --version
danemacmillan@macmillanator.local ~ $ linus deploy:update -v --
--ansi                    --load-config             --no-ansi                 --no-integrity-check      --quiet                   --save-config-all         --verbose
--help                    --merge-develop           --no-cleanup              --no-interaction          --save-config             --save-config-before-run  --version

Notice that in the first ouput I'm not provided a suggestion to use the --merge-develop or --no-integrity-check options, and only see the global options, while in the second output, I see all the global options as well as the specific options for the given argument name.

Has anyone else noticed this?

@danemacmillan danemacmillan changed the title Specifiying short option immediately after command prevents specific long options for arguments Specifiying global option immediately after console name prevents specific long options for arguments from completing Feb 21, 2018
@stecman stecman added the bug label Mar 31, 2018
stecman added a commit that referenced this issue Apr 29, 2019
The CompletionHandler code made an assumption that the command name
was always the second word on the command line:

    $ [program-name] [command-name] [...arguments and options]

This now searches for the first non-option-like word and stores its
index for other parts of CompletionHandler to test against.

The way ArrayInput is built in `CompletionHandler::getInput()` doesn't
align with how the docs for that class expect it to be used, so calling
`getFirstArgument()` was always returning the first value.

Fixes #83
@stecman stecman closed this as completed in 7bfa9b9 May 6, 2019
@danemacmillan
Copy link
Author

Thanks!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants