mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-25 12:23:09 +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,20 +1,13 @@
|
|||
|
||||
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
|
||||
switch $argv[1]
|
||||
case -h --h --he --hel --help
|
||||
__fish_print_help funcsave
|
||||
return 0
|
||||
end
|
||||
else
|
||||
printf (_ "%s: Expected function name\n") funcsave
|
||||
if set -q _flag_help
|
||||
__fish_print_help funcsave
|
||||
return 1
|
||||
return 0
|
||||
end
|
||||
|
||||
set -l res 0
|
||||
|
||||
set -l configdir ~/.config
|
||||
if set -q XDG_CONFIG_HOME
|
||||
set configdir $XDG_CONFIG_HOME
|
||||
|
@ -29,11 +22,12 @@ function funcsave --description "Save the current definition of all specified fu
|
|||
end
|
||||
end
|
||||
|
||||
for i in $argv
|
||||
if functions -q -- $i
|
||||
functions -- $i >$configdir/fish/functions/$i.fish
|
||||
set -l res 0
|
||||
for funcname in $argv
|
||||
if functions -q -- $funcname
|
||||
functions -- $i >$configdir/fish/functions/$funcname
|
||||
else
|
||||
printf (_ "%s: Unknown function '%s'\n") funcsave $i
|
||||
printf (_ "%s: Unknown function '%s'\n") funcsave $funcname
|
||||
set res 1
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue