fork/fish-shell
git clone https://git.julia.blue/fork/fish-shell
dd9784296
master
1complete -c rustc -s h -l help 2 3complete -c rustc -x -l cfg 4complete -c rustc -x -l check-cfg -d"Provide list of expected cfgs for checking" 5complete -c rustc -r -s L -a'dependency= crate= native= framework= all=' 6complete -c rustc -x -s l -a'dylib= static= framework=' 7complete -c rustc -x -l crate-type -a'bin lib rlib dylib cdylib staticlib proc-macro' 8complete -c rustc -r -l crate-name 9complete -c rustc -x -l edition -a'2015 2018 2021' -d"Specify compiler edition" 10complete -c rustc -x -l emit -a'asm llvm-bc llvm-ir obj link dep-info metadata mir' 11complete -c rustc -x -l print -d"Print compiler information" -xa"(rustc --print fake 2>&1 | string match -arg '`(.*?)`' | string match -v fake)" 12complete -c rustc -s g -d"Equivalent to -C debuginfo=2" 13complete -c rustc -s O -d"Equivalent to -C opt-level=2" 14complete -c rustc -r -s o -d"Write output to <filename>" 15complete -c rustc -r -l out-dir 16complete -c rustc -x -l explain 17complete -c rustc -l test 18complete -c rustc -l target -xa"(rustc --print target-list)" 19complete -c rustc -x -l cap-lints 20complete -c rustc -s V -l version -d'Print version info and exit' 21complete -c rustc -s v -l verbose -d'Use verbose output' 22complete -c rustc -f -l extern 23complete -c rustc -f -l sysroot 24complete -c rustc -x -l color -a'auto always never' 25 26complete -c rustc -s C -l codegen -xa"(rustc -C help 2>/dev/null | string match -rv 'option is deprecated' | string replace -rf -i '(\s+)-C\s*(.+)=val(\s+)--(\s+)([^\n]+)' '\$2='\t'\$5')" 27 28# rustc -Z is only available with the nightly toolchain, which may not be installed 29function __fish_rustc_z_completions 30# This function takes a little over one second to run, so let's cache it. (It's ok if the first run is slow 31# since this is only run when specifically completing `rustc -Z<TAB>` and not when the completion is loaded.) 32if set -q __fish_cached_rustc_z_completions 33printf '%s\n' $__fish_cached_rustc_z_completions 34return 35end 36 37if not command -q rustup;or not rustup toolchain list| string match -q'nightly*' 38return 39end 40 41set -l rust_docs( rustc +nightly -Z help2> /dev/null| 42string replace -r'^\s+' '' | string replace -ar' +' ' ' | string replace -r'=val +-- +' '=\t' ) 43 44set -f flag 45set -f docs 46set -g __fish_cached_rustc_z_completions( for linein $rust_docs 47# Handle multi-line completions for options with values, e.g. 48# -Z unpretty=val -- present the input source, unstable (and less-pretty) variants; 49# `normal`, `identified`, 50# `expanded`, `expanded,identified`, 51# `expanded,hygiene` (with internal representations) 52if string match -rq'^-Z' --$line 53# Actual -Z completion 54set -l parts( string split --\t $line ) 55set flag( string replace -r --'-Z\s*' '' $parts [ 1 ]) 56set docs$parts [ 2 ] 57printf '%s\t%s\n' $flag $docs 58else 59# Check for possible argument followed by description, supporting multiple completions per line 60# Don't split on ',' but rather ', ' to preserve commas in backticks 61# echo $flag: 62for linein ( string split', ' --$line | string trim -c',' | string trim) 63# echo \* $line 64if set -l parts( string match -gr'^(?:or )?`=?(.*?)`\s*(?:\((.*?)\)|: (.*))?\s*' --$line ) 65set -l docs$parts [ 2 ] $parts [ 3 ] 66printf '%s%s\t%s\n' $flag $parts [ 1 ] $docs 67else if set -l parts( string match -gr'^([a-z-]+):?\s*(.*)' --$line ) 68printf '%s%s\t%s\n' $flag $parts [ 1 ] $parts [ 2 ] 69end | string match -ev'=val' 70end 71end 72end ) 73__fish_rustc_z_completions 74end 75complete -c rustc -x -s Z -ka"(__fish_rustc_z_completions)" 76 77function __fish_rustc_lint_completions 78rustc -W help2> /dev/null\ 79| string match -r\ 80'(?:\s+)(?:.+)(?:\s+)(?:allow|warn|deny|forbid)(?:\s+){2}(?:[^\n]+)' \ 81| string replace -r -i\ 82'(\s+)(.+)(\s+)(allow|warn|deny|forbid)(\s+){2}([^\n]+)' '$2 $6' \ 83| string match -r'^.*[^:]$' \ 84| string match -r -v'^(allow|warn|deny|forbid)$' \ 85| string match -r -v'^([a-z\-]+)(\s+)(allow|warn|deny|forbid)' \ 86| string replace' ' ,\t 87end 88 89# Support multiple arguments in one parameter as comma-separated values with `__fish_concat_completions`, 90# combined with printing the name with a trailing , above. 91complete -c rustc -s W -l warn -xa"(__fish_rustc_lint_completions | __fish_concat_completions)" -d"Warn on lint" 92complete -c rustc -s A -l allow -xa"(__fish_rustc_lint_completions | __fish_concat_completions)" -d"Allow lint" 93complete -c rustc -s D -l deny -xa"(__fish_rustc_lint_completions | __fish_concat_completions)" -d"Deny lint" 94complete -c rustc -s F -l forbid -xa"(__fish_rustc_lint_completions | __fish_concat_completions)" -d"Forbid lint"