From 89541b73fa4d013ae75840260ab3e0c01b19c2f5 Mon Sep 17 00:00:00 2001 From: Nabanita Dash Date: Wed, 17 Jul 2019 02:59:09 +0530 Subject: [PATCH] Autocompletion of commands and files (#2226) * changed " to ' * autocompletion of commands and files * Revert "autocompletion of commands and files" This reverts commit 0b394ec841c68357cec6eb1cfa2cb20b636d3739. revert the changes made * changed * bash complete * modified * shows subcommands but not files * modified --- scripts/completion/dvc.bash | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/scripts/completion/dvc.bash b/scripts/completion/dvc.bash index c9b0b5f68..c9d66dd3e 100644 --- a/scripts/completion/dvc.bash +++ b/scripts/completion/dvc.bash @@ -16,7 +16,8 @@ _dvc_options='-h --help -V --version' _dvc_global_options='-h --help -q --quiet -v --verbose' _dvc_add='-R --recursive -f --file --no-commit $(compgen -G *)' -_dvc_cache='' +_dvc_cache='dir' +_dvc_cache_dir=' --global --system --local -u --unset' _dvc_checkout='-f --force -d --with-deps -R --recursive $(compgen -G *.dvc)' _dvc_commit='-f --force -d --with-deps -R --recursive $(compgen -G *.dvc)' _dvc_config='-u --unset --local --system --global' @@ -31,12 +32,23 @@ _dvc_import='-o --out --rev' _dvc_init='--no-scm -f --force' _dvc_install='' _dvc_lock='$(compgen -G *.dvc)' -_dvc_metrics='' +_dvc_metrics='add modify rmeove show' +_dvc_metrics_add='-t --type -x --xpath $(compgen -G *)' +_dvc_metrics_modify='-t --type -x --xpath $(compgen -G *)' +_dvc_metrics_remove='$(compgen -G *)' +_dvc_metrics_show='$(-t --type -x --xpath -a --all-branches -T --all-tags -R --recursive $(compgen -G *)' _dvc_move='$(compgen -G *)' -_dvc_pipeline='' +_dvc_pipeline='list show' +_dvc_pipeline_list='' +_dvc_pipeline_show='-c --commands -o --outs --ascii --dot --tree -l --locked $(compgen -G *.dvc)' _dvc_pull='--show-checksums -j --jobs -r --remote -a --all-branches -T --all-tags -f --force -d --with-deps -R --recursive $(compgen -G *.dvc)' _dvc_push='--show-checksums -j --jobs -r --remote -a --all-branches -T --all-tags -d --with-deps -R --recursive $(compgen -G *.dvc)' -_dvc_remote='' +_dvc_remote='add default list modify remove' +_dvc_remote_add='--global --system --local -d --default -f --force' +_dvc_remote_default='--global --system --local -u --unset' +_dvc_remote_list='--global --system --local' +_dvc_remote_modify='--global --system --local -u --unset' +_dvc_remote_remove='--global --system --local' _dvc_remove='-o --outs -p --purge -f --force $(compgen -G *.dvc)' _dvc_repro='-f --force -s --single-item -c --cwd -m --metrics --dry -i --interactive -p --pipeline -P --all-pipelines --ignore-build-cache --no-commit -R --recursive --downstream $(compgen -G *.dvc)' _dvc_root='' @@ -72,6 +84,10 @@ _dvc () { elif [ "${COMP_CWORD}" -eq 2 ]; then local options_list="_dvc_${COMP_WORDS[1]}" + COMPREPLY=($(compgen -W "$_dvc_global_options ${!options_list}" -- "$word")) + elif [ "${COMP_CWORD}" -eq 3 ]; then + local options_list="_dvc_${COMP_WORDS[1]}_${COMP_WORDS[2]}" + COMPREPLY=($(compgen -W "$_dvc_global_options ${!options_list}" -- "$word")) fi