Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

scripts: Zsh completion should work with subcommands #1924

Closed
ghost opened this issue Apr 24, 2019 · 4 comments
Closed

scripts: Zsh completion should work with subcommands #1924

ghost opened this issue Apr 24, 2019 · 4 comments
Labels
enhancement Enhances DVC p3-nice-to-have It should be done this or next sprint

Comments

@ghost
Copy link

ghost commented Apr 24, 2019

For example: dvc metrics show <tab>.

The way to support this would be to modify the way we parse our arguments to support subcommands

$_dvc_options \
'1: :_dvc_commands' \
'*::args:->args'
case $words[1] in
init) _arguments $_dvc_global_options $_dvc_init ;;
destroy) _arguments $_dvc_global_options $_dvc_destroy ;;
add) _arguments $_dvc_global_options $_dvc_add ;;
import) _arguments $_dvc_global_options $_dvc_import ;;
checkout) _arguments $_dvc_global_options $_dvc_checkout ;;

@ghost ghost added the enhancement Enhances DVC label Apr 24, 2019
@jorgeorpinel
Copy link
Contributor

jorgeorpinel commented May 29, 2019

I just want to add that specifically for dvc cache dir not all the $_dvc_global_options exist (-q, and -v specifically), while for all the other subcommands I think they do. Something to consider. (Maybe they should be added to the subcommand?)

@efiop
Copy link
Contributor

efiop commented May 29, 2019

@jorgeorpinel Good catch! Indeed, we've missed those there. Looks like we just need to use parents=[parent_parser, parent_config_parser] in https://github.com/iterative/dvc/blob/master/dvc/command/cache.py#L46 .

@efiop efiop added p3-nice-to-have It should be done this or next sprint and removed p4 labels Sep 25, 2019
@casperdcl
Copy link
Contributor

also see https://stackoverflow.com/questions/9000698/completion-when-program-has-sub-commands

@efiop
Copy link
Contributor

efiop commented Dec 7, 2020

@efiop efiop closed this as completed Dec 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhances DVC p3-nice-to-have It should be done this or next sprint
Projects
None yet
Development

No branches or pull requests

3 participants