mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 12:53:13 +00:00
update funcsave
to use argparse
This commit is contained in:
parent
6ecd0bcb32
commit
86af63cd39
1 changed files with 10 additions and 16 deletions
|
@ -1,19 +1,12 @@
|
||||||
|
|
||||||
function funcsave --description "Save the current definition of all specified functions to file"
|
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
|
||||||
|
or return
|
||||||
|
|
||||||
if count $argv >/dev/null
|
if set -q _flag_help
|
||||||
switch $argv[1]
|
|
||||||
case -h --h --he --hel --help
|
|
||||||
__fish_print_help funcsave
|
__fish_print_help funcsave
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
else
|
|
||||||
printf (_ "%s: Expected function name\n") funcsave
|
|
||||||
__fish_print_help funcsave
|
|
||||||
return 1
|
|
||||||
end
|
|
||||||
|
|
||||||
set -l res 0
|
|
||||||
|
|
||||||
set -l configdir ~/.config
|
set -l configdir ~/.config
|
||||||
if set -q XDG_CONFIG_HOME
|
if set -q XDG_CONFIG_HOME
|
||||||
|
@ -29,11 +22,12 @@ function funcsave --description "Save the current definition of all specified fu
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for i in $argv
|
set -l res 0
|
||||||
if functions -q -- $i
|
for funcname in $argv
|
||||||
functions -- $i >$configdir/fish/functions/$i.fish
|
if functions -q -- $funcname
|
||||||
|
functions -- $i >$configdir/fish/functions/$funcname
|
||||||
else
|
else
|
||||||
printf (_ "%s: Unknown function '%s'\n") funcsave $i
|
printf (_ "%s: Unknown function '%s'\n") funcsave $funcname
|
||||||
set res 1
|
set res 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue