diff --git a/share/completions/conda.fish b/share/completions/conda.fish index 55d2d98ac..b2dc6f594 100644 --- a/share/completions/conda.fish +++ b/share/completions/conda.fish @@ -29,9 +29,9 @@ function __fish_conda_subcommand # get the commandline args without the "conda" set -l toks (commandline -xpc)[2..-1] - # Remove any important options - if we had options with arguments, + # if we had options with arguments, # they'd need to be listed here to be removed. - argparse -i h/help v/version -- $toks 2>/dev/null + argparse -u -- $toks 2>/dev/null # Return false if it fails - this shouldn't really happen, # so all bets are off or return 2 @@ -44,19 +44,12 @@ function __fish_conda_subcommand if test "$subcmds[1]" = "$argv[1]" set -e argv[1] set -e subcmds[1] - else if string match -q -- '-*' $argv[1] - set -e argv[1] else return 1 end end - # Skip any remaining options. - while string match -q -- '-*' $argv[1] - set -e argv[1] - end - - # If we have no subcommand left, + # If we have no subcommand # we either matched all given subcommands or we need one. if not set -q argv[1] return $have_sub diff --git a/share/completions/iwctl.fish b/share/completions/iwctl.fish index 687fd3c28..529b5eedc 100644 --- a/share/completions/iwctl.fish +++ b/share/completions/iwctl.fish @@ -8,10 +8,10 @@ function __iwctl_filter -w iwctl # awk does not work on multiline entries, therefore we use string match, # which has the added benefit of filtering out the `No devices in ...` lines - argparse -i all-columns -- $argv + argparse -u all-columns -- $argv # remove color escape sequences - set -l results (iwctl $argv | string replace -ra '\e\[[\d;]+m' '') + set -l results (iwctl $argv_opts -- $argv | string replace -ra '\e\[[\d;]+m' '') # calculate column widths set -l headers $results[3] # We exploit the fact that all column labels will have >2 space to the left, and inside column labels there is always only one space. @@ -38,7 +38,7 @@ function __iwctl_match_subcoms set argv (commandline -pxc) # iwctl allows to specify arguments for username, password, passphrase and dont-ask regardless of any following commands - argparse -i 'u/username=' 'p/password=' 'P/passphrase=' v/dont-ask -- $argv + argparse -u 'u/username=' 'p/password=' 'P/passphrase=' v/dont-ask -- $argv set argv $argv[2..] if test (count $argv) != (count $match) @@ -55,7 +55,7 @@ end function __iwctl_connect set argv (commandline -pxc) # remove all options - argparse -i 'u/username=' 'p/password=' 'P/passphrase=' v/dont-ask -- $argv + argparse -u 'u/username=' 'p/password=' 'P/passphrase=' v/dont-ask -- $argv # station name should now be the third argument (`iwctl station `) for network in (__iwctl_filter station $argv[3] get-networks rssi-dbms --all-columns) set network (string split \t -- $network) diff --git a/share/completions/meson.fish b/share/completions/meson.fish index b3cb3d88a..76b48a2a9 100644 --- a/share/completions/meson.fish +++ b/share/completions/meson.fish @@ -20,7 +20,7 @@ end function __fish_meson_builddir # Consider the value of -C option to detect the build directory set -l cmd (commandline -xpc) - argparse -i 'C=' -- $cmd + argparse -u 'C=' -- $cmd if set -q _flag_C echo $_flag_C else diff --git a/share/completions/ninja.fish b/share/completions/ninja.fish index 9e9d2b084..9908e76b5 100644 --- a/share/completions/ninja.fish +++ b/share/completions/ninja.fish @@ -1,7 +1,7 @@ function __fish_ninja set -l saved_args $argv set -l dir . - if argparse -i C/dir= -- (commandline -xpc) + if argparse -u C/dir= -- (commandline -xpc) command ninja -C$_flag_C $saved_args end end diff --git a/share/completions/yadm.fish b/share/completions/yadm.fish index d5c50d50c..814158ea0 100644 --- a/share/completions/yadm.fish +++ b/share/completions/yadm.fish @@ -61,11 +61,13 @@ function __fish_complete_yadm_like_git set -l yadm_work_tree (yadm gitconfig --get core.worktree) set -l yadm_repo (yadm introspect repo) - argparse -i 'R-yadm-repo=' -- $cmdline 2>/dev/null + argparse -u 'R-yadm-repo=&' -- $cmdline 2>/dev/null if set -q _flag_yadm_repo set yadm_repo $_flag_yadm_repo - # argparse *always* sets $argv to remaining arguments after consuming specified options - set cmdline $argv + # argparse -u *always* sets $argv to remaining arguments after consuming all options, + # and it *always* sets $argv_opts to any specified non-& options and any unknown options + # (the -- is needed in case $argv originally contained a -- followed by arguments starting with a -) + set cmdline $argv_opts -- $argv end set -l git_wrapper_cmd "git --work-tree $yadm_work_tree --git-dir $yadm_repo $cmdline" diff --git a/share/functions/__fish_complete_mysql.fish b/share/functions/__fish_complete_mysql.fish index 7ded690a8..1aad3d79e 100644 --- a/share/functions/__fish_complete_mysql.fish +++ b/share/functions/__fish_complete_mysql.fish @@ -1,5 +1,5 @@ function __fish_mysql_query -a query - argparse -i 'u/user=' 'P/port=' 'h/host=' 'p/password=?' 'S/socket=' -- (commandline -px) + argparse -u 'u/user=' 'P/port=' 'h/host=' 'p/password=?' 'S/socket=' -- (commandline -px) set -l mysql_cmd mysql for flag in u P h S if set -q _flag_$flag diff --git a/share/functions/__fish_seen_argument.fish b/share/functions/__fish_seen_argument.fish index 7266458c3..3153f4f00 100644 --- a/share/functions/__fish_seen_argument.fish +++ b/share/functions/__fish_seen_argument.fish @@ -1,5 +1,5 @@ function __fish_seen_argument --description 'Check whether argument is used' - argparse --ignore-unknown 's/short=+' 'o/old=+' 'l/long=+' 'w/windows=+' -- $argv + argparse --move-unknown 's/short=+&' 'o/old=+&' 'l/long=+&' 'w/windows=+&' -- $argv set --local tokens (commandline --current-process --tokens-expanded --cut-at-cursor) set --erase tokens[1] @@ -30,7 +30,7 @@ function __fish_seen_argument --description 'Check whether argument is used' end end - for raw_arg in $argv + for raw_arg in $argv_opts $argv if string match --quiet -- $t $raw_arg return 0 end