completions/cargo: enforce color off

Signed-off-by: Benjamin VERGNAUD <ben@bvergnaud.fr>
This commit is contained in:
Benjamin VERGNAUD
2025-05-06 12:56:05 +02:00
parent c2eaef7273
commit 11d8b83838

View File

@@ -1,20 +1,25 @@
# Tab completion for cargo (https://github.com/rust-lang/cargo).
## --- WRITTEN MANUALLY ---
set -l __fish_cargo_subcommands (cargo --list 2>&1 | string replace -rf '^\s+([^\s]+)\s*(.*)' '$1\t$2' | string escape)
function __fish_cargo
cargo --color=never $argv
end
set -l __fish_cargo_subcommands (__fish_cargo --list 2>&1 | string replace -rf '^\s+([^\s]+)\s*(.*)' '$1\t$2' | string escape)
complete -c cargo -f -c cargo -n __fish_use_subcommand -a "$__fish_cargo_subcommands"
complete -c cargo -x -c cargo -n '__fish_seen_subcommand_from help' -a "$__fish_cargo_subcommands"
for x in bench b build c check rustc t test
complete -c cargo -x -n "__fish_seen_subcommand_from $x" -l bench -a "(cargo bench --bench 2>&1 | string replace -rf '^\s+' '')"
complete -c cargo -x -n "__fish_seen_subcommand_from $x" -l bench -a "(__fish_cargo bench --bench 2>&1 | string replace -rf '^\s+' '')"
complete -c cargo -n "__fish_seen_subcommand_from $x" -l lib -d 'Only this package\'s library'
complete -c cargo -x -n "__fish_seen_subcommand_from $x" -l test -a "(cargo test --test 2>&1 | string replace -rf '^\s+' '')"
complete -c cargo -x -n "__fish_seen_subcommand_from $x" -l test -a "(__fish_cargo test --test 2>&1 | string replace -rf '^\s+' '')"
end
for x in bench b build c check r run rustc t test
complete -c cargo -x -n "__fish_seen_subcommand_from $x" -l bin -a "(cargo run --bin 2>&1 | string replace -rf '^\s+' '')"
complete -c cargo -x -n "__fish_seen_subcommand_from $x" -l example -a "(cargo run --example 2>&1 | string replace -rf '^\s+' '')"
complete -c cargo -x -n "__fish_seen_subcommand_from $x" -l bin -a "(__fish_cargo run --bin 2>&1 | string replace -rf '^\s+' '')"
complete -c cargo -x -n "__fish_seen_subcommand_from $x" -l example -a "(__fish_cargo run --example 2>&1 | string replace -rf '^\s+' '')"
end
# If using rustup, get the list of installed targets from there. Otherwise print all targets.
@@ -38,18 +43,18 @@ end
function __fish_cargo_features
if command -q jq
cargo read-manifest | jq -r '.features | keys | .[]' | __fish_concat_completions
__fish_cargo read-manifest | jq -r '.features | keys | .[]' | __fish_concat_completions
else if set -l python (__fish_anypython)
cargo read-manifest | command $python -Sc "import sys, json"\n"print(*json.load(sys.stdin)['features'].keys(), sep='\n')" | __fish_concat_completions
__fish_cargo read-manifest | command $python -Sc "import sys, json"\n"print(*json.load(sys.stdin)['features'].keys(), sep='\n')" | __fish_concat_completions
end
end
function __fish_cargo_packages
if command -q jq
cargo metadata --no-deps --format-version 1 | jq -r '.packages | .[] | .name' | __fish_concat_completions
__fish_cargo metadata --no-deps --format-version 1 | jq -r '.packages | .[] | .name' | __fish_concat_completions
else if set -l python (__fish_anypython)
cargo metadata --no-deps --format-version 1 |
command $python -Sc "import sys, json"\n"print(*[x['name'] for x in json.load(sys.stdin)['packages']], sep='\n')"
__fish_cargo metadata --no-deps --format-version 1 |
command $python -Sc "import sys, json"\n"print(*[x['name'] for x in json.load(sys.stdin)['packages']], sep='\n')"
end
end
complete -c cargo -n '__fish_seen_subcommand_from run test build debug check clippy' -s p -l package \
@@ -60,7 +65,7 @@ complete -c cargo -n '__fish_seen_subcommand_from run test build debug check cli
complete -c cargo -n __fish_use_subcommand -l explain -d 'Run `rustc --explain CODE`'
complete -c cargo -n __fish_use_subcommand -l color -d 'Coloring: auto, always, never'
complete -c cargo -n __fish_use_subcommand -l config -d 'Override a configuration value (unstable)'
complete -c cargo -n __fish_use_subcommand -s Z -d 'Unstable (nightly-only) flags to Cargo, see \'cargo -Z help\' for details' -xa '(cargo -Z help | string replace -rf \'^\s*-Z (\S+)\s+(.*)\' \'$1\t$2\')'
complete -c cargo -n __fish_use_subcommand -s Z -d 'Unstable (nightly-only) flags to Cargo, see \'cargo -Z help\' for details' -xa '(__fish_cargo -Z help | string replace -rf \'^\s*-Z (\S+)\s+(.*)\' \'$1\t$2\')'
complete -c cargo -n __fish_use_subcommand -s V -l version -d 'Print version info and exit'
complete -c cargo -n __fish_use_subcommand -l list -d 'List installed commands'
complete -c cargo -n __fish_use_subcommand -s v -l verbose -d 'Use verbose output (-vv very verbose/build.rs output)'
@@ -841,8 +846,8 @@ if command -q cargo-asm
# Warning: this will build the project and can take time! We make sure to only call it if it's not a switch so completions
# for --foo will always be fast.
if command -q timeout
complete -c cargo -n "__fish_seen_subcommand_from asm; and not __fish_is_switch" -xa "(timeout 1 cargo asm)"
complete -c cargo -n "__fish_seen_subcommand_from asm; and not __fish_is_switch" -xa "(timeout 1 __fish_cargo asm)"
else
complete -c cargo -n "__fish_seen_subcommand_from asm; and not __fish_is_switch" -xa "(cargo asm)"
complete -c cargo -n "__fish_seen_subcommand_from asm; and not __fish_is_switch" -xa "(__fish_cargo asm)"
end
end