diff --git a/dvc/cli/completion.py b/dvc/cli/completion.py index 5d2025bf8..e1f82c586 100644 --- a/dvc/cli/completion.py +++ b/dvc/cli/completion.py @@ -22,6 +22,11 @@ _dvc_compgen_exps() { local _dvc_exps=($(dvc exp list -q --all-commits --names-only)) compgen -W "${_dvc_exps[*]}" -- $1 } + +_dvc_compgen_remotes() { + local _dvc_remotes=($(dvc remote list | cut -d' ' -f1)) + compgen -W "${_dvc_remotes[*]}" -- $1 +} """ ZSH_PREAMBLE = """ @@ -55,6 +60,10 @@ _dvc_compadd_stages_and_files() { _dvc_compadd_exps() { _describe 'experiments' "($(dvc exp list -q --all-commits --names-only))" } + +_dvc_compadd_remotes() { + _describe 'remotes' "($(dvc remote list | cut -d' ' -f1))" +} """ PREAMBLE = { @@ -71,3 +80,4 @@ DVCFILES_AND_STAGE = { "zsh": "_dvc_compadd_stages_and_files", } EXPERIMENT = {"bash": "_dvc_compgen_exps", "zsh": "_dvc_compadd_exps"} +REMOTE = {"bash": "_dvc_compgen_remotes", "zsh": "_dvc_compadd_remotes"} diff --git a/dvc/commands/add.py b/dvc/commands/add.py index 38146b30e..9f2a584b1 100644 --- a/dvc/commands/add.py +++ b/dvc/commands/add.py @@ -101,7 +101,7 @@ def add_parser(subparsers, parent_parser): "--remote", help="Remote storage to download to", metavar="", - ) + ).complete = completion.REMOTE parser.add_argument( "--remote-jobs", type=int, diff --git a/dvc/commands/artifacts.py b/dvc/commands/artifacts.py index 38a8b2796..06cfc221d 100644 --- a/dvc/commands/artifacts.py +++ b/dvc/commands/artifacts.py @@ -149,7 +149,7 @@ def add_parser(subparsers, parent_parser): "Remote name to set as a default in the target repository " "(only applicable when downloading from DVC remote)." ), - ) + ).complete = completion.REMOTE get_parser.add_argument( "--remote-config", type=str, diff --git a/dvc/commands/data.py b/dvc/commands/data.py index fb5fd5958..a7a43f265 100644 --- a/dvc/commands/data.py +++ b/dvc/commands/data.py @@ -133,9 +133,12 @@ class CmdDataStatus(CmdBase): def add_parser(subparsers, parent_parser): + data_help = "Commands related to data management." data_parser = subparsers.add_parser( "data", parents=[parent_parser], + description=append_doc_link(data_help, "data/status"), + help=data_help, formatter_class=formatter.RawDescriptionHelpFormatter, ) data_subparsers = data_parser.add_subparsers( @@ -193,7 +196,7 @@ def add_parser(subparsers, parent_parser): "--remote", help="Remote storage to check (only applicable with --not-in-remote).", metavar="", - ) + ).complete = completion.REMOTE data_status_parser.add_argument( "--not-in-remote", action="store_true", diff --git a/dvc/commands/data_sync.py b/dvc/commands/data_sync.py index 22c09bed1..8f46e6821 100644 --- a/dvc/commands/data_sync.py +++ b/dvc/commands/data_sync.py @@ -150,7 +150,7 @@ def add_parser(subparsers, _parent_parser): ) pull_parser.add_argument( "-r", "--remote", help="Remote storage to pull from", metavar="" - ) + ).complete = completion.REMOTE pull_parser.add_argument( "-a", "--all-branches", @@ -225,7 +225,7 @@ def add_parser(subparsers, _parent_parser): ) push_parser.add_argument( "-r", "--remote", help="Remote storage to push to", metavar="" - ) + ).complete = completion.REMOTE push_parser.add_argument( "-a", "--all-branches", @@ -287,7 +287,7 @@ def add_parser(subparsers, _parent_parser): ) fetch_parser.add_argument( "-r", "--remote", help="Remote storage to fetch from", metavar="" - ) + ).complete = completion.REMOTE fetch_parser.add_argument( "-a", "--all-branches", @@ -380,7 +380,7 @@ def add_parser(subparsers, _parent_parser): "--remote", help="Remote storage to compare local cache to", metavar="", - ) + ).complete = completion.REMOTE status_parser.add_argument( "-a", "--all-branches", diff --git a/dvc/commands/du.py b/dvc/commands/du.py index 486695c5f..d089d0331 100644 --- a/dvc/commands/du.py +++ b/dvc/commands/du.py @@ -60,7 +60,7 @@ def add_parser(subparsers, parent_parser): "--remote", type=str, help="Remote name to set as a default in the target repository.", - ) + ).complete = completion.REMOTE du_parser.add_argument( "--remote-config", type=str, diff --git a/dvc/commands/experiments/pull.py b/dvc/commands/experiments/pull.py index c7a97a466..d55c48ec2 100644 --- a/dvc/commands/experiments/pull.py +++ b/dvc/commands/experiments/pull.py @@ -1,6 +1,6 @@ import argparse -from dvc.cli import formatter +from dvc.cli import completion, formatter from dvc.cli.command import CmdBase from dvc.cli.utils import append_doc_link from dvc.log import logger @@ -71,7 +71,7 @@ def add_parser(experiments_subparsers, parent_parser): dest="dvc_remote", metavar="", help="Name of the DVC remote to use when pulling cached outputs.", - ) + ).complete = completion.REMOTE experiments_pull_parser.add_argument( "-j", "--jobs", diff --git a/dvc/commands/experiments/push.py b/dvc/commands/experiments/push.py index 505f2b241..d48a738c7 100644 --- a/dvc/commands/experiments/push.py +++ b/dvc/commands/experiments/push.py @@ -111,7 +111,7 @@ def add_parser(experiments_subparsers, parent_parser): dest="dvc_remote", metavar="", help="Name of the DVC remote to use when pushing cached outputs.", - ) + ).complete = completion.REMOTE experiments_push_parser.add_argument( "-j", "--jobs", diff --git a/dvc/commands/gc.py b/dvc/commands/gc.py index 0a993db59..63026222f 100644 --- a/dvc/commands/gc.py +++ b/dvc/commands/gc.py @@ -1,6 +1,6 @@ import os -from dvc.cli import formatter +from dvc.cli import completion, formatter from dvc.cli.command import CmdBase from dvc.cli.utils import append_doc_link from dvc.log import logger @@ -188,7 +188,7 @@ def add_parser(subparsers, parent_parser): "--remote", help="Remote storage to collect garbage in", metavar="", - ) + ).complete = completion.REMOTE gc_parser.add_argument( "--skip-failed", action="store_true", diff --git a/dvc/commands/get.py b/dvc/commands/get.py index 2bbf39f2a..92fa9aa36 100644 --- a/dvc/commands/get.py +++ b/dvc/commands/get.py @@ -121,7 +121,7 @@ def add_parser(subparsers, parent_parser): "--remote", type=str, help="Remote name to set as a default in the target repository.", - ) + ).complete = completion.REMOTE get_parser.add_argument( "--remote-config", type=str, diff --git a/dvc/commands/imp.py b/dvc/commands/imp.py index 9b1437757..edc7c879a 100644 --- a/dvc/commands/imp.py +++ b/dvc/commands/imp.py @@ -115,7 +115,7 @@ def add_parser(subparsers, parent_parser): "--remote", type=str, help="Remote name to set as a default in the target repository.", - ) + ).complete = completion.REMOTE import_parser.add_argument( "--remote-config", type=str, diff --git a/dvc/commands/imp_url.py b/dvc/commands/imp_url.py index 24e725463..c4f854b78 100644 --- a/dvc/commands/imp_url.py +++ b/dvc/commands/imp_url.py @@ -73,7 +73,7 @@ def add_parser(subparsers, parent_parser): "--remote", help="Remote storage to download to", metavar="", - ) + ).complete = completion.REMOTE no_download_exec_group = import_parser.add_mutually_exclusive_group() no_download_exec_group.add_argument( "--no-exec", diff --git a/dvc/commands/ls/__init__.py b/dvc/commands/ls/__init__.py index bfc1bd675..d409d7ec2 100644 --- a/dvc/commands/ls/__init__.py +++ b/dvc/commands/ls/__init__.py @@ -250,7 +250,7 @@ def add_parser(subparsers, parent_parser): "--remote", type=str, help="Remote name to set as a default in the target repository.", - ) + ).complete = completion.REMOTE list_parser.add_argument( "--remote-config", type=str, diff --git a/dvc/commands/remote.py b/dvc/commands/remote.py index 325eeda25..bf727cadf 100644 --- a/dvc/commands/remote.py +++ b/dvc/commands/remote.py @@ -1,4 +1,4 @@ -from dvc.cli import formatter +from dvc.cli import completion, formatter from dvc.cli.utils import append_doc_link from dvc.commands.config import CmdConfig from dvc.ui import ui @@ -210,7 +210,9 @@ def add_parser(subparsers, parent_parser): help=REMOTE_DEFAULT_HELP, formatter_class=formatter.RawDescriptionHelpFormatter, ) - remote_default_parser.add_argument("name", nargs="?", help="Name of the remote") + remote_default_parser.add_argument( + "name", nargs="?", help="Name of the remote" + ).complete = completion.REMOTE remote_default_parser.add_argument( "-u", "--unset", @@ -228,7 +230,9 @@ def add_parser(subparsers, parent_parser): help=REMOTE_MODIFY_HELP, formatter_class=formatter.RawDescriptionHelpFormatter, ) - remote_modify_parser.add_argument("name", help="Name of the remote") + remote_modify_parser.add_argument( + "name", help="Name of the remote" + ).complete = completion.REMOTE remote_modify_parser.add_argument("option", help="Name of the option to modify.") remote_modify_parser.add_argument( "value", nargs="?", help="(optional) Value of the option." @@ -260,7 +264,9 @@ def add_parser(subparsers, parent_parser): help=REMOTE_REMOVE_HELP, formatter_class=formatter.RawDescriptionHelpFormatter, ) - remote_remove_parser.add_argument("name", help="Name of the remote to remove.") + remote_remove_parser.add_argument( + "name", help="Name of the remote to remove." + ).complete = completion.REMOTE remote_remove_parser.set_defaults(func=CmdRemoteRemove) REMOTE_RENAME_HELP = "Rename a DVC remote" remote_rename_parser = remote_subparsers.add_parser( diff --git a/dvc/commands/update.py b/dvc/commands/update.py index 660e03764..9cb6eeb80 100644 --- a/dvc/commands/update.py +++ b/dvc/commands/update.py @@ -74,7 +74,7 @@ def add_parser(subparsers, parent_parser): "--remote", help="Remote storage to perform updates to", metavar="", - ) + ).complete = completion.REMOTE update_parser.add_argument( "-j", "--jobs",