fork/fish-shell
git clone https://git.julia.blue/fork/fish-shell
ab7d52d72
master
1set -l subcmds\ 2 show\ 3 update\ 4 default\ 5 toolchain\ 6 target\ 7 component\ 8 override\ 9 run\ 10 which\ 11 doc\ 12 man\ 13 self\ 14 set\ 15# "completions" \ 16help 17 18set -l rustup_show\ 19 active-toolchain\ 20 home\ 21 profile\ 22 help 23 24# rustup does not really expose a mechanism of retrieving a list of all valid components without the archs appended 25# Just print the list of installable x86_64-unknown-linux-gnu components for everyone 26function __rustup_components 27rustup component list| string match -r"\S+" | string replace -rf --"-x86_64-unknown-linux-gnu.*" "" | sort -u 28end 29 30function __rustup_installed_components 31# If the user has supplied `--toolchain foo`, use it to filter the list 32set -l toolchain( commandline -j| string replace -rf".*\s--toolchain\s+(\S+)\s.*" '$1' ) 33set -l toolchain_filter 34if string match -qr . --$toolchain 35set toolchain_filter"--toolchain $toolchain " 36end 37 38rustup component list --installed$toolchain_filter | string replace -r --( printf --"-%s\n" ( __rustup_targets ) | string join"|" ) "" | sort -u 39 40end 41 42function __rustup_installable_components 43comm -2 -3 ( __rustup_components | psub -F) ( __rustup_installed_components | psub -F) 44end 45 46# All *valid* target triples, retrieved from source 47function __rustup_triples 48# The list below must be kept sorted alphabetically 49printf "%s\n" \ 50 aarch64-apple-ios\ 51 aarch64-linux-android\ 52 aarch64-pc-windows-msvc\ 53 aarch64-unknown-cloudabi\ 54 aarch64-unknown-fuchsia\ 55 aarch64-unknown-linux-gnu\ 56 aarch64-unknown-linux-musl\ 57 aarch64-unknown-redox\ 58 armebv7r-none-eabi\ 59 armebv7r-none-eabihf\ 60 arm-linux-androideabi\ 61 arm-unknown-linux-gnueabi\ 62 arm-unknown-linux-gnueabihf\ 63 arm-unknown-linux-musleabi\ 64 arm-unknown-linux-musleabihf\ 65 armv5te-unknown-linux-gnueabi\ 66 armv5te-unknown-linux-musleabi\ 67 armv7-apple-ios\ 68 armv7-linux-androideabi\ 69 armv7r-none-eabi\ 70 armv7r-none-eabihf\ 71 armv7s-apple-ios\ 72 armv7-unknown-cloudabi-eabihf\ 73 armv7-unknown-linux-gnueabi\ 74 armv7-unknown-linux-gnueabihf\ 75 armv7-unknown-linux-musleabi\ 76 armv7-unknown-linux-musleabihf\ 77 asmjs-unknown-emscripten\ 78 i386-apple-ios\ 79 i586-pc-windows-msvc\ 80 i586-unknown-linux-gnu\ 81 i586-unknown-linux-musl\ 82 i686-apple-darwin\ 83 i686-linux-android\ 84 i686-pc-windows-gnu\ 85 i686-pc-windows-msvc\ 86 i686-unknown-cloudabi\ 87 i686-unknown-freebsd\ 88 i686-unknown-haiku\ 89 i686-unknown-linux-gnu\ 90 i686-unknown-linux-musl\ 91 i686-unknown-netbsd\ 92 le32-unknown-nacl\ 93 mips64el-unknown-linux-gnuabi64\ 94 mips64-unknown-linux-gnuabi64\ 95 mipsel-unknown-linux-gnu\ 96 mipsel-unknown-linux-musl\ 97 mipsel-unknown-linux-uclibc\ 98 mipsisa32r6el-unknown-linux-gnu\ 99 mipsisa32r6-unknown-linux-gnu\ 100 mipsisa64r6el-unknown-linux-gnuabi64\ 101 mipsisa64r6-unknown-linux-gnuabi64\ 102 mips-unknown-linux-gnu\ 103 mips-unknown-linux-musl\ 104 mips-unknown-linux-uclibc\ 105 msp430-none-elf\ 106 nvptx64-nvidia-cuda\ 107 powerpc64le-unknown-linux-gnu\ 108 powerpc64-unknown-linux-gnu\ 109 powerpc-unknown-linux-gnu\ 110 powerpc-unknown-linux-gnuspe\ 111 riscv32imac-unknown-none-elf\ 112 riscv32imc-unknown-none-elf\ 113 riscv32i-unknown-none-elf\ 114 riscv64gc-unknown-none-elf\ 115 riscv64imac-unknown-none-elf\ 116 s390x-unknown-linux-gnu\ 117 sparc64-unknown-linux-gnu\ 118 sparc64-unknown-netbsd\ 119 sparc-unknown-linux-gnu\ 120 sparcv9-sun-solaris\ 121 thumbv6m-none-eabi\ 122 thumbv7em-none-eabi\ 123 thumbv7em-none-eabihf\ 124 thumbv7m-none-eabi\ 125 thumbv7neon-linux-androideabi\ 126 thumbv7neon-unknown-linux-gnueabihf\ 127"thumbv8m.base-none-eabi" \ 128"thumbv8m.main-none-eabi" \ 129"thumbv8m.main-none-eabihf" \ 130 wasm32-unknown-emscripten\ 131 wasm32-unknown-unknown\ 132 x86_64-apple-darwin\ 133 x86_64-apple-ios\ 134 x86_64-fortanix-unknown-sgx\ 135 x86_64-linux-android\ 136 x86_64-pc-solaris\ 137 x86_64-pc-windows-gnu\ 138 x86_64-pc-windows-msvc\ 139 x86_64-rumprun-netbsd\ 140 x86_64-sun-solaris\ 141 x86_64-unknown-bitrig\ 142 x86_64-unknown-cloudabi\ 143 x86_64-unknown-dragonfly\ 144 x86_64-unknown-freebsd\ 145 x86_64-unknown-fuchsia\ 146 x86_64-unknown-haiku\ 147 x86_64-unknown-linux-gnu\ 148 x86_64-unknown-linux-gnux32\ 149 x86_64-unknown-linux-musl\ 150 x86_64-unknown-netbsd\ 151 x86_64-unknown-openbsd\ 152 x86_64-unknown-redox 153end 154 155# Given n arguments, return the longest suffix common to all 156function __rustup_common_suffix 157if test ( count $argv ) -le 1 158return 159end 160 161set -l index-1 162set -l min_length65335 163for argin $argv 164if test ( string length" $arg " ) -lt $min_length 165set min_length( string length" $arg " ) 166end 167end 168 169set -l length1 170set -l suffix 171set -l done0 172while test $done -eq 0 -a $length -le $min_length 173set -l match( string match -r --".{ $length }\$" " $argv [ 1 ] " ) 174for argin $argv [ 2 .. -1 ] 175set -l value( string match -r --".{ $length }\$" " $arg " ) 176if test " $value " = " $match " 177continue 178else if string match -qr -- ." $suffix " 179set done1 180break 181else 182# No common suffix 183return 1 184end 185end 186set suffix" $match " 187set length( math $length +1 ) 188end 189 190printf "%s\n" " $suffix " 191end 192 193# Strip result of __rustup_common_suffix 194function __rustup_strip_common_suffix 195set -l suffix( __rustup_common_suffix $argv ) 196printf "%s\n" $argv | string replace -r --( string escape --style=regex --" $suffix " ) \$ "" 197end 198 199# Strip result of __rustup_common_suffix, but require suffix to begin at a literal - 200function __rustup_strip_common_suffix_strict 201set -l suffix( __rustup_common_suffix $argv | string match -r --"-.*" ) 202printf "%s\n" $argv | string replace -r --( string escape --style=regex --" $suffix " ) \$ "" 203end 204 205function __rustup_all_toolchains 206set -l __rustup_channels beta stable nightly 207printf "%s\n" $__rustup_channels 208printf "%s\n" $__rustup_channels -( __rustup_triples ) 209end 210 211# All valid toolchains excluding installed 212function __rustup_installable_toolchains 213comm -2 -3 ( __rustup_all_toolchains | psub -F) ( printf "%s\n" $__rustup_toolchains | psub -F) \ 214# Ignore warnings about lists not being in sorted order, as we are aware of their contents 2152 > /dev/null 216end 217 218function __rustup_targets 219rustup target list| string replace -rf"^(\S+).*" '$1' 220end 221 222function __rustup_installed_targets 223rustup target list| string replace -rf"^(\S+) \(installed\)" '$1' 224end 225 226# All valid targets excluding installed 227function __rustup_installable_targets 228rustup target list| string match -rv'\(installed\)$' 229end 230 231# Trim trailing attributes, e.g. "rust-whatever (default)" -> "rust-whatever" 232set -l __rustup_toolchains( rustup toolchain list| string replace -r"\s+.*" '' ) 233# By default, the long name of a toolchain is used (e.g. nightly-x86_64-unknown-linux-gnu), 234# but a shorter version can be used if it is unambiguous. 235set -l __rustup_toolchains_short( __rustup_strip_common_suffix_strict $__rustup_toolchains ) 236 237set -l rustup_profiles minimal default complete 238 239complete -c rustup -n __fish_should_complete_switches -s v -l verbose 240complete -c rustup -n __fish_should_complete_switches -s h -l help 241complete -c rustup -n __fish_should_complete_switches -s V -l version 242 243complete -c rustup -n"__fish_is_nth_token 1" -xa" $subcmds " 244 245complete -c rustup -n"__fish_prev_arg_in default" -xa" $__rustup_toolchains_short $__rustup_toolchains " 246complete -c rustup -n"__fish_prev_arg_in toolchain" -xa"add install list remove uninstall link help" 247complete -c rustup -n"__fish_prev_arg_in target" -xa"list add install remove uninstall help" 248complete -c rustup -n"__fish_prev_arg_in component" -xa"list add install remove uninstall help" 249complete -c rustup -n"__fish_prev_arg_in override" -xa"list set unset help" 250complete -c rustup -n"__fish_prev_arg_in run" -xa" $__rustup_toolchains_short $__rustup_toolchains " 251complete -c rustup -n"__fish_prev_arg_in self" -xa"update remove uninstall upgrade-data help" 252complete -c rustup -n"__fish_prev_arg_in set" -xa"default-host profile help" 253 254complete -c rustup -n"__fish_seen_subcommand_from toolchain; and __fish_prev_arg_in remove uninstall" \ 255 -xa" $__rustup_toolchains $__rustup_toolchains_short " 256complete -c rustup -n"__fish_seen_subcommand_from toolchain; and __fish_prev_arg_in add install" \ 257 -xa"(__rustup_installable_toolchains)" 258 259complete -c rustup -n"__fish_seen_subcommand_from component; and __fish_prev_arg_in remove uninstall" \ 260 -xa"(__rustup_installed_components)" 261complete -c rustup -n"__fish_seen_subcommand_from component; and __fish_prev_arg_in add install" \ 262 -xa"(__rustup_installable_components)" 263 264complete -c rustup -n"__fish_seen_subcommand_from target; and __fish_prev_arg_in add install" \ 265 -xa"(__rustup_installable_targets)" 266complete -c rustup -n"__fish_seen_subcommand_from target; and __fish_prev_arg_in remove uninstall" \ 267 -xa"(__rustup_installed_targets)" 268 269complete -c rustup -n"__fish_seen_subcommand_from show;" -xa" $rustup_show " 270 271complete -c rustup -n"__fish_seen_subcommand_from set; and __fish_prev_arg_in default-host" \ 272 -xa"(__rustup_triples)" 273 274complete -c rustup -n"__fish_seen_subcommand_from set; and __fish_prev_arg_in profile" \ 275 -xa" $rustup_profiles " 276 277# Global argument completions where valid 278complete -c rustup -n"__fish_prev_arg_in --toolchain" -xa" $__rustup_toolchains_short $__rustup_toolchains " 279 280complete -f -c rustup -n'__fish_seen_subcommand_from doc' -a'(__fish_rustup_docs_primitives)' 281complete -f -c rustup -n'__fish_seen_subcommand_from doc' -a'(__fish_rustup_docs_keywords)' 282complete -f -c rustup -n'__fish_seen_subcommand_from doc' -a'(__fish_rustup_docs_macros)' 283complete -f -c rustup -n'__fish_seen_subcommand_from doc' -a'(__fish_rustup_docs_modules)' 284 285function __fish_rustup_docs_modules 286set -l doc_path( __rustup_doc_path ) 287command find" $doc_path " /{ std, core, alloc} -name index.html\ 288| string replace --regex" $doc_path /(.+)/index\.html" '$1\tModule' \ 289| string replace --all / :: 290end 291 292function __fish_rustup_docs_keywords 293set -l doc_path( __rustup_doc_path ) 294string replace --regex" $doc_path /std/keyword\.(.+)\.html" '$1\tKeyword' " $doc_path " /std/keyword.*.html 295end 296 297function __fish_rustup_docs_primitives 298set -l doc_path( __rustup_doc_path ) 299string replace --regex" $doc_path /std/primitive\.(.+)\.html" '$1\tPrimitive' " $doc_path " /std/primitive.*.html 300end 301 302function __fish_rustup_docs_macros 303set -l doc_path( __rustup_doc_path ) 304string replace --regex" $doc_path /" '' " $doc_path " /{ std, core, alloc} /macro.*.html\ 305| string replace --regex'macro\.(.+)\.html' '$1\tMacro' \ 306| string replace --all / :: 307end 308 309function __rustup_doc_path 310rustup doc --path| string replace --regex'/[^/]*$' '' 311end