From 0b7bbb56543e8cd8dfa52204c49f50ce048ae883 Mon Sep 17 00:00:00 2001 From: Jason Nader Date: Sat, 22 Feb 2020 20:28:03 +0900 Subject: [PATCH] cleanup completions: localise/erase vars where possible [skip-ci] --- share/completions/cargo.fish | 7 +++---- share/completions/mplayer.fish | 4 +--- share/completions/rpm.fish | 19 ++++++------------- share/completions/rustc.fish | 3 --- share/completions/rustup.fish | 6 ++---- share/completions/setfacl.fish | 4 +--- share/completions/zfs.fish | 4 ++-- 7 files changed, 15 insertions(+), 32 deletions(-) diff --git a/share/completions/cargo.fish b/share/completions/cargo.fish index 2f0114342..edfbf774d 100644 --- a/share/completions/cargo.fish +++ b/share/completions/cargo.fish @@ -7,10 +7,10 @@ complete -c cargo -l list -d 'List installed commands' complete -c cargo -s v -l verbose -d 'Use verbose output' complete -c cargo -s q -l quiet -d 'No output printed to stdout' -set __fish_cargo_subcommands (cargo --list 2>&1 | string replace -rf '^\s+([^\s]+)\s+(.*)' '$1\t$2') +set -l __fish_cargo_subcommands (cargo --list 2>&1 | string replace -rf '^\s+([^\s]+)\s+(.*)' '$1\t$2') -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' +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 build clean doc fetch generate-lockfile \ locate-project package pkgid publish \ @@ -88,4 +88,3 @@ complete -c cargo -x -n '__fish_seen_subcommand_from update' -l precise -d 'Upda complete -c cargo -x -n '__fish_seen_subcommand_from yank' -l vers -d 'The version to yank or un-yank' complete -c cargo -n '__fish_seen_subcommand_from yank' -l undo -d 'Undo a yank, putting a version back into the index' - diff --git a/share/completions/mplayer.fish b/share/completions/mplayer.fish index 9eee41158..7b4c070bd 100644 --- a/share/completions/mplayer.fish +++ b/share/completions/mplayer.fish @@ -6,7 +6,7 @@ # incomplete. Please send in additions. # -set mplayer_lang " +set -l mplayer_lang " de\tGerman dk\tDanish en\tEnglish @@ -81,5 +81,3 @@ complete -c mplayer -o vfm -x -d "Video output" -a " complete -c mplayer -l help -d "Display help and exit" complete -c mplayer -l version -d "Display version and exit" - -set -e mplayer_lang diff --git a/share/completions/rpm.fish b/share/completions/rpm.fish index f4c6fe6a0..53d2f4b18 100644 --- a/share/completions/rpm.fish +++ b/share/completions/rpm.fish @@ -18,7 +18,7 @@ complete -c rpm -l root -d "Specify root directory for rpm operations" -a " ) " -set rpm_install -c rpm -n "__fish_contains_opt -s i -s U -s F install upgrade freshen" +set -l rpm_install -c rpm -n "__fish_contains_opt -s i -s U -s F install upgrade freshen" complete $rpm_install -l aid -d "Add suggested packages to the transaction set when needed" complete $rpm_install -l allfiles -d "Installs or upgrades all the files in the package, even if they aren't needed (missingok) and don't exist" complete $rpm_install -l badreloc -d "Used with --relocate, permit relocations on all file paths, not just those OLD-PATH's included in the binary package relocation hint(s)" @@ -53,9 +53,8 @@ complete $rpm_install -l repackage -d 'Re-package the files before erasing' complete $rpm_install -l replacefiles -d 'Install the packages even if they replace files from other, already installed, packages' complete $rpm_install -l replacepkgs -d 'Install the packages even if some of them are already installed on this system' complete $rpm_install -l test -d "Don't install the package, simply check for and report potential conflicts" -set -e rpm_install -set rpm_query -c rpm -n "__fish_contains_opt -s q query" +set -l rpm_query -c rpm -n "__fish_contains_opt -s q query" complete $rpm_query -l changelog -d 'Display change information for the package' complete $rpm_query -s c -l configfiles -d 'List only configuration files (implies -l)' complete $rpm_query -s d -l docfiles -d 'List only documentation files (implies -l)' @@ -70,10 +69,8 @@ complete $rpm_query -l scripts -d 'List the package specific scriptlets' complete $rpm_query -s s -l state -d 'Display the states of files in the package. The state of each file is one of normal, not installed, or replaced' complete $rpm_query -l triggers -d 'Display the trigger scripts contained in the package' complete $rpm_query -l triggerscripts -d 'Display the trigger scripts contained in the package' -set -e rpm_query - -set rpm_select -c rpm -n "__fish_contains_opt -s q -s V query verify" +set -l rpm_select -c rpm -n "__fish_contains_opt -s q -s V query verify" complete $rpm_select -a "(__fish_print_packages)" complete $rpm_select -s a -l all -d 'Query all installed packages' complete $rpm_select -s f -l file -d 'Query package owning specified file' -rF @@ -87,9 +84,8 @@ complete $rpm_select -l tid -d 'Query package(s) that have the specified TID (tr complete $rpm_select -l triggeredby -d 'Query packages that are triggered by the specified packages' -x -a "(__fish_print_packages)" complete $rpm_select -l whatprovides -d 'Query all packages that provide the specified capability' -x complete $rpm_select -l whatrequires -d 'Query all packages that requires the specified capability for functioning' -x -set -e rpm_select -set rpm_verify -c rpm -n "__fish_contains_opt -s V verify" +set -l rpm_verify -c rpm -n "__fish_contains_opt -s V verify" complete $rpm_verify -l nodeps -d "Don't verify dependencies of packages" complete $rpm_verify -l nodigest -d "Don't verify package or header digests when reading" complete $rpm_verify -l nofiles -d "Don't verify any attributes of package files" @@ -103,9 +99,8 @@ complete $rpm_verify -l nogroup -d "Don't verify group attribute" complete $rpm_verify -l nomtime -d "Don't verify time attribute" complete $rpm_verify -l nomode -d "Don't verify mode attribute" complete $rpm_verify -l nordev -d "Don't verify dev attribute" -set -e rpm_verify -set rpm_erase -c rpm -n "__fish_contains_opt -s e erase" +set -l rpm_erase -c rpm -n "__fish_contains_opt -s e erase" complete $rpm_erase -a "(__fish_print_packages)" complete $rpm_erase -l allmatches -d 'Remove all versions of the package which match specified string' complete $rpm_erase -l nodeps -d "Don't check dependencies before uninstalling the packages" @@ -117,15 +112,13 @@ complete $rpm_erase -l notriggerun -d "Don't execute triggerun scriptlets" complete $rpm_erase -l notriggerpostun -d "Don't execute triggerpostun scriptlets" complete $rpm_erase -l repackage -d 'Re-package the files before erasing' complete $rpm_erase -l test -d "Don't really uninstall anything" -set -e rpm_erase -set rpm_mode -c rpm -n 'not __fish_contains_opt -s e -s i -s F -s V -s U -s q erase install freshen verify upgrade query' +set -l rpm_mode -c rpm -n 'not __fish_contains_opt -s e -s i -s F -s V -s U -s q erase install freshen verify upgrade query' complete $rpm_mode -s i -l install -d 'Install new package' complete $rpm_mode -s U -l upgrade -d 'Upgrade existing package' complete $rpm_mode -s F -l freshen -d 'Upgrade package if already installed' complete $rpm_mode -s q -l query -d 'Query installed packages' complete $rpm_mode -s V -l verify -d 'Verify package integrity' complete $rpm_mode -s e -l erase -d 'Erase package' -set -e rpm_mode complete -c rpm -xa '(__fish_complete_suffix .rpm)' diff --git a/share/completions/rustc.fish b/share/completions/rustc.fish index 17dc499a5..444eeba50 100644 --- a/share/completions/rustc.fish +++ b/share/completions/rustc.fish @@ -67,6 +67,3 @@ for line in $rust_docs complete -c rustc -x -s D -l deny -a (string escape -- "$docs[1]") -d "$docs[2]" complete -c rustc -x -s F -l forbid -a (string escape -- "$docs[1]") -d "$docs[2]" end - -set -e rust_codegen - diff --git a/share/completions/rustup.fish b/share/completions/rustup.fish index f61bc1293..fac9fb143 100644 --- a/share/completions/rustup.fish +++ b/share/completions/rustup.fish @@ -194,6 +194,7 @@ function __rustup_strip_common_suffix_strict end function __rustup_all_toolchains + set -l __rustup_channels "beta" "stable" "nightly" printf "%s\n" $__rustup_channels printf "%s\n" $__rustup_channels-(__rustup_triples) end @@ -223,10 +224,7 @@ set -l __rustup_toolchains (rustup toolchain list | string replace -r "\s+.*" '' # but a shorter version can be used if it is unambiguous. set -l __rustup_toolchains_short (__rustup_strip_common_suffix_strict $__rustup_toolchains) -# Needs to be global to retain access from functions -set __rustup_channels "beta" "stable" "nightly" - -set rustup_profiles "minimal" "default" "complete" +set -l rustup_profiles "minimal" "default" "complete" complete -c rustup -n "__fish_should_complete_switches" -s v -l verbose complete -c rustup -n "__fish_should_complete_switches" -s h -l help diff --git a/share/completions/setfacl.fish b/share/completions/setfacl.fish index 4352a5f12..f1cf0e0c4 100644 --- a/share/completions/setfacl.fish +++ b/share/completions/setfacl.fish @@ -1,7 +1,5 @@ -set __fish_facl_spec_keywords default user group mask other - function __fish_facl_list_spec_keyword - for keyword in $__fish_facl_spec_keywords + for keyword in default user group mask other echo $keyword: end end diff --git a/share/completions/zfs.fish b/share/completions/zfs.fish index 6b008fb49..b18f8101a 100644 --- a/share/completions/zfs.fish +++ b/share/completions/zfs.fish @@ -10,7 +10,7 @@ # - for the program command, complete the script to be executed # - for commands accepting several arguments of different types, propose arguments in the right order: for get, once the ZFS parameters have been given, only propose datasets -set OS "" +set -lx OS "" switch (uname) case Linux set OS "Linux" @@ -90,7 +90,7 @@ function __fish_zfs_list_groupspace_types echo -e "all\t"(_ "Both types") end -function __fish_zfs_list_permissions +function __fish_zfs_list_permissions -V OS echo -e "allow\t"(_ "Also needs the permission to be allowed") echo -e "clone\t"(_ "Also needs the 'create' and 'mount' permissions in the origin filesystem") echo -e "create\t"(_ "Also needs the 'mount' permission")