fork/fish-shell
git clone https://git.julia.blue/fork/fish-shell
4a12d5771
master
1function __fish_argparse_exclusive_args --description'Helper function to list unused options' 2set --local all_tokens( commandline --tokens-expanded) 3set --erase all_tokens[ 1 ] 4set --local current_token( commandline --current-token) 5 6if set --local index( contains --index --'--' $all_tokens ) 7set index( math $index -1 ) 8else 9set index( count $all_tokens ) 10end 11 12set --local specifications 13while test $index -gt 0 14and set -l tok$all_tokens [ $index ] 15and not string match --quiet --'-*' $tok 16 17if string match --quiet'*,*' $tok 18set index( math $index -1 ) 19continue 20end 21 22set -l opt( string replace --regex'=.*' '' $tok ) 23 24if string match --quiet'*/*' $opt 25set --append specifications( string split'/' $opt ) 26else if string match --quiet'*#*' $opt 27set --append specifications( string split'#' $opt ) 28else 29set --append specifications$opt 30end 31set index( math $index -1 ) 32end 33 34if string match --quiet --'-x*' $current_token 35set current_token( string replace --regex --'^-x' '' $current_token ) 36end 37 38if test $index -gt 1 39and string match --regex --quiet --'^(-x|--exclusive)$' $all_tokens [( math $index - 1 )] 40and not test -z $current_token 41set --erase specifications[( count $specifications )] 42end 43 44set --local used_options( string split --',' $current_token ) 45set --local unused_specifications 46 47for itemin $specifications 48if not contains --$item $used_options 49set --append unused_specifications$item 50end 51end 52 53string join\n $unused_specifications 54end 55 56complete --command argparse --no-files 57 58complete --command argparse --short-option h --long-option help --description'Show help' 59 60complete --command argparse --short-option n --long-option name --require-parameter --no-files\ 61 --arguments'(functions --all | string replace ", " "\n")' --description'Use function name' 62complete --command argparse --short-option x --long-option exclusive --no-files --require-parameter\ 63 --arguments'(__fish_append "," (__fish_argparse_exclusive_args))' \ 64 --description'Specify mutually exclusive options' 65complete --command argparse --short-option N --long-option min-args --no-files --require-parameter\ 66 --description'Specify minimum non-option argument count' 67complete --command argparse --short-option X --long-option max-args --no-files --require-parameter\ 68 --description'Specify maximum non-option argument count' 69complete --command argparse --short-option i --long-option ignore-unknown\ 70 -n'! __fish_seen_argument --short u --long move-unknown' \ 71 --description'Ignore unknown options' 72complete --command argparse --short-option u --long-option move-unknown\ 73 -n'! __fish_seen_argument --short i --long ignore-unknown' \ 74 --description'Move unknown options into \$argv_opts' 75complete --command argparse --short-option S --long-option strict-longopts\ 76 --description'Pass long options strictly' 77complete --command argparse --short-option U --long-option unknown-arguments --no-files --require-parameter\ 78 --arguments"optional required none" \ 79 --description'Whether unknown options can have arguments' 80complete --command argparse --short-option s --long-option stop-nonopt\ 81 --description'Exit on subcommand'