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

Tab completion for --target uses rustup but fallsback to rustc #12606

Merged
merged 2 commits into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/etc/_cargo
Original file line number Diff line number Diff line change
Expand Up @@ -407,9 +407,15 @@ _cargo_cmds() {
}

_cargo_target_triple() {
local -a targets
targets=( ${(f)"$(rustc --print target-list)"} )
_describe 'target triple' targets
local -a result

if (( $+commands[rustup] )); then
result=( ${(f)"$(rustup target list --installed)"} )
else
result=( ${(f)"$(rustc --print target-list)"} )
fi

_describe 'target triple' result
}

#FIXME: Disabled until fixed
Expand Down
14 changes: 5 additions & 9 deletions src/etc/cargo.bashcomp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -250,15 +250,11 @@ _get_examples(){
}

_get_targets(){
local result=()
local targets=$(rustup target list)
while read line
do
if [[ "$line" =~ default|installed ]]; then
result+=("${line%% *}")
fi
done <<< "$targets"
echo "${result[@]}"
if command -v rustup >/dev/null 2>/dev/null; then
rustup target list --installed
else
rustc --print target-list
fi
}

_toolchains(){
Expand Down