Skip to content

Commit 1d9ded9

Browse files
committed
Auto merge of rust-lang#10577 - epage:add-complete, r=ehuss
Completion support for `cargo-add` ### What does this PR try to resolve? cargo-add's PR was minimal to ensure we had settled on the CLI before adding references to the CLI and have cascading churn. This updates bash and zsh completion to include cargo-add. ### How should we test and review this PR? I am unsure how to handle testing of completions, so this is a best-effort from looking at other completions and the docs. ### Additional information To keep the PRs focused, I am submitting completions separate from documentation updates so one does not get blocked on the other and its easier to see all relevant parts and sign off on them.
2 parents 25cc78e + d0aa75e commit 1d9ded9

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/etc/_cargo

+20
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,26 @@ _cargo() {
6666
args)
6767
curcontext="${curcontext%:*}-${words[1]}:"
6868
case ${words[1]} in
69+
add)
70+
_arguments -s -A "^--" $common $manifest $registry \
71+
{-F+,--features=}'[specify features to activate]:feature'
72+
"--default-features[enable the default features]"
73+
"--no-default-features[don't enable the default features]"
74+
"--optional[mark the dependency as optional]"
75+
"--no-optional[mark the dependency as required]"
76+
"--dev[add as a dev dependency]"
77+
"--build[add as a build dependency]"
78+
"--target=[add as a dependency to the given target platform]"
79+
"--rename=[rename the dependency]"
80+
"--dry-run[don't actually write the manifest]"
81+
'--branch=[branch to use when adding from git]:branch' \
82+
'--git=[specify URL from which to add the crate]:url:_urls' \
83+
'--path=[local filesystem path to crate to add]: :_directories' \
84+
'--rev=[specific commit to use when adding from git]:commit' \
85+
'--tag=[tag to use when adding from git]:tag' \
86+
'1: :_guard "^-*" "crate name"' \
87+
'*:args:_default'
88+
;;
6989
bench)
7090
_arguments -s -A "^--" $common $parallel $features $msgfmt $triple $target $manifest \
7191
"${command_scope_spec[@]}" \

src/etc/cargo.bashcomp.sh

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ _cargo()
4848
local opt_targets="--lib --bin --bins --example --examples --test --tests --bench --benches --all-targets"
4949

5050
local opt___nocmd="$opt_common -V --version --list --explain"
51+
local opt__add="$opt_common -p --package --features --default-features --no-default-features $opt_mani --optional --no-optional --rename --dry-run --path --git --branch --tag --rev --registry --dev --build --target"
5152
local opt__bench="$opt_common $opt_pkg_spec $opt_feat $opt_mani $opt_lock $opt_parallel $opt_targets --message-format --target --no-run --no-fail-fast --target-dir"
5253
local opt__build="$opt_common $opt_pkg_spec $opt_feat $opt_mani $opt_lock $opt_parallel $opt_targets --message-format --target --release --profile --target-dir"
5354
local opt__b="$opt__build"

0 commit comments

Comments
 (0)