completion: complete remote in zsh/bash (#10858)

This commit is contained in:
skshetry
2025-08-31 11:25:31 +05:45
committed by GitHub
parent a8bda305cd
commit 6f4b8c98fc
15 changed files with 41 additions and 22 deletions
+10
View File
@@ -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"}
+1 -1
View File
@@ -101,7 +101,7 @@ def add_parser(subparsers, parent_parser):
"--remote",
help="Remote storage to download to",
metavar="<name>",
)
).complete = completion.REMOTE
parser.add_argument(
"--remote-jobs",
type=int,
+1 -1
View File
@@ -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,
+4 -1
View File
@@ -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="<name>",
)
).complete = completion.REMOTE
data_status_parser.add_argument(
"--not-in-remote",
action="store_true",
+4 -4
View File
@@ -150,7 +150,7 @@ def add_parser(subparsers, _parent_parser):
)
pull_parser.add_argument(
"-r", "--remote", help="Remote storage to pull from", metavar="<name>"
)
).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="<name>"
)
).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="<name>"
)
).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="<name>",
)
).complete = completion.REMOTE
status_parser.add_argument(
"-a",
"--all-branches",
+1 -1
View File
@@ -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,
+2 -2
View File
@@ -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="<name>",
help="Name of the DVC remote to use when pulling cached outputs.",
)
).complete = completion.REMOTE
experiments_pull_parser.add_argument(
"-j",
"--jobs",
+1 -1
View File
@@ -111,7 +111,7 @@ def add_parser(experiments_subparsers, parent_parser):
dest="dvc_remote",
metavar="<name>",
help="Name of the DVC remote to use when pushing cached outputs.",
)
).complete = completion.REMOTE
experiments_push_parser.add_argument(
"-j",
"--jobs",
+2 -2
View File
@@ -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="<name>",
)
).complete = completion.REMOTE
gc_parser.add_argument(
"--skip-failed",
action="store_true",
+1 -1
View File
@@ -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,
+1 -1
View File
@@ -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,
+1 -1
View File
@@ -73,7 +73,7 @@ def add_parser(subparsers, parent_parser):
"--remote",
help="Remote storage to download to",
metavar="<name>",
)
).complete = completion.REMOTE
no_download_exec_group = import_parser.add_mutually_exclusive_group()
no_download_exec_group.add_argument(
"--no-exec",
+1 -1
View File
@@ -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,
+10 -4
View File
@@ -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(
+1 -1
View File
@@ -74,7 +74,7 @@ def add_parser(subparsers, parent_parser):
"--remote",
help="Remote storage to perform updates to",
metavar="<name>",
)
).complete = completion.REMOTE
update_parser.add_argument(
"-j",
"--jobs",