Make --help work

See #5361.
This commit is contained in:
Fabian Homborg 2018-11-22 12:43:35 +01:00
parent b383e29a24
commit 3a835ebd61
4 changed files with 24 additions and 4 deletions

View File

@ -13,7 +13,7 @@ end
function funced --description 'Edit function definition'
set -l options 'h/help' 'e/editor=' 'i/interactive' 's/save'
argparse -n funced --min-args=1 --max-args=1 $options -- $argv
argparse -n funced --max-args=1 $options -- $argv
or return
if set -q _flag_help
@ -21,6 +21,11 @@ function funced --description 'Edit function definition'
return 0
end
if not set -q argv[1]
printf (_ "%ls: Expected at least %d args, got only %d\n") funced 1 0
return 1
end
set funcname $argv[1]
# Check VISUAL first since theoretically EDITOR could be ed.

View File

@ -1,6 +1,6 @@
function funcsave --description "Save the current definition of all specified functions to file"
set -l options 'h/help'
argparse -n funcsave --min-args=1 $options -- $argv
argparse -n funcsave $options -- $argv
or return
if set -q _flag_help
@ -8,6 +8,11 @@ function funcsave --description "Save the current definition of all specified fu
return 0
end
if not set -q argv[1]
printf (_ "%ls: Expected at least %d args, got only %d\n") funcsave 1 0
return 1
end
if not mkdir -p $__fish_config_dir/functions
printf (_ "%s: Could not create configuration directory\n") funcsave
return 1

View File

@ -5,7 +5,7 @@
if not command -sq open
function open --description "Open file in default application"
set -l options 'h/help'
argparse -n open --min-args=1 $options -- $argv
argparse -n open $options -- $argv
or return
if set -q _flag_help
@ -13,6 +13,11 @@ if not command -sq open
return 0
end
if not set -q argv[1]
printf (_ "%ls: Expected at least %d args, got only %d\n") open 1 0
return 1
end
if type -q -f cygstart
for i in $argv
cygstart $i

View File

@ -25,7 +25,7 @@ function realpath -d "return an absolute path without symlinks"
set -l options 'h/help' 'q/quiet' 'V-version' 's/strip' 'N-no-symlinks' 'z/zero'
set -a options 'e/canonicalize-existing' 'm/canonicalize-missing' 'L/logical' 'P/physical'
set -a options 'R-relative-to=' 'B-relative-base='
argparse -n realpath --min-args=1 $options -- $argv
argparse -n realpath $options -- $argv
or return
if set -q _flag_help
@ -42,6 +42,11 @@ function realpath -d "return an absolute path without symlinks"
return 1
end
if not set -q argv[1]
printf (_ "%ls: Expected at least %d args, got only %d\n") realpath 1 0
return 1
end
for path in $argv
builtin realpath $path
end