all repos — scriptura @ 8f4320e8825448b3642b6e1dde31aad53dee43c2

a corner in $HOME for your scripts

move completion descriptions to function definitions

Alin
commit

8f4320e8825448b3642b6e1dde31aad53dee43c2

parent

e2bef6abcb519abcc37d0024d08319b20f76d6b1

M completions/scriptura.fishcompletions/scriptura.fish
@@ -9,37 +9,37 @@
complete --command scriptura \ --condition __fish_use_subcommand \ --exclusive \ - --description 'Run a script' \ + --description (__scriptura_describe_function __scriptura_run) \ --arguments run complete --command scriptura \ --condition __fish_use_subcommand \ --exclusive \ - --description 'Display help information' \ + --description (__scriptura_describe_function __scriptura_help) \ --arguments help complete --command scriptura \ --condition __fish_use_subcommand \ --exclusive \ - --description 'Create new script' \ + --description (__scriptura_describe_function __scriptura_new) \ --arguments new complete --command scriptura \ --condition __fish_use_subcommand \ --exclusive \ - --description 'Edit existing script' \ + --description (__scriptura_describe_function __scriptura_edit) \ --arguments edit complete --command scriptura \ --condition __fish_use_subcommand \ --exclusive \ - --description 'Display script content' \ + --description (__scriptura_describe_function __scriptura_cat) \ --arguments cat complete --command scriptura \ --condition __fish_use_subcommand \ --exclusive \ - --description 'Display script path' \ + --description (__scriptura_describe_function __scriptura_which) \ --arguments which complete --command scriptura \
M functions/__scriptura_args.fishfunctions/__scriptura_args.fish
@@ -1,2 +1,2 @@
-function __scriptura_args +function __scriptura_args --description 'Parse arguments for scriptura' end
M functions/__scriptura_cat.fishfunctions/__scriptura_cat.fish
@@ -1,4 +1,4 @@
-function __scriptura_cat --argument-names script_path +function __scriptura_cat --description 'Display script content' --argument-names script_path if not set --query SCRIPTURA_CAT if set --query SD_CAT set --function SCRIPTURA_CAT $SD_CAT
@@ -8,4 +8,4 @@ end
end eval $SCRIPTURA_CAT $script_path -end+end
M functions/__scriptura_complete_new.fishfunctions/__scriptura_complete_new.fish
@@ -1,4 +1,4 @@
-function __scriptura_complete_new +function __scriptura_complete_new --description 'Complete arguments for new subcommand' test (count $argv) -ne 0 or set --function argv (commandline -xpc)[3..] (commandline -ct)
M functions/__scriptura_complete_script.fishfunctions/__scriptura_complete_script.fish
@@ -1,4 +1,4 @@
-function __scriptura_complete_script +function __scriptura_complete_script --description 'Complete script names' set --function from $SCRIPTURA_ROOT test (count $argv) -ne 0
M functions/__scriptura_desc.fishfunctions/__scriptura_desc.fish
@@ -1,3 +1,3 @@
-function __scriptura_desc --argument-names file +function __scriptura_desc --description 'Extract description from script file' --argument-names file string match --groups-only --regex '^#\s*([^!].*)$' <$file | string join "\n" end
A functions/__scriptura_describe_function.fish
@@ -0,0 +1,3 @@
+function __scriptura_describe_function --description 'Describe a function' + echo (functions --verbose --details $argv[1])[-1] +end
M functions/__scriptura_edit.fishfunctions/__scriptura_edit.fish
@@ -1,4 +1,4 @@
-function __scriptura_edit --argument-names script_path +function __scriptura_edit --description 'Edit existing script' --argument-names script_path if not set --query SCRIPTURA_EDITOR set --function SCRIPTURA_EDITOR $( if set --query SD_EDITOR
M functions/__scriptura_help.fishfunctions/__scriptura_help.fish
@@ -1,4 +1,4 @@
-function __scriptura_help --argument-names file_or_dir +function __scriptura_help --description 'Display help information' --argument-names file_or_dir if path is --type dir $file_or_dir set --function help_file $file_or_dir/help else
@@ -15,4 +15,3 @@ else
echo "Unknown type" end end -
M functions/__scriptura_list.fishfunctions/__scriptura_list.fish
@@ -1,4 +1,4 @@
-function __scriptura_list --argument-names from +function __scriptura_list --description 'List scripts and directories' --argument-names from for dir in $(path filter --type dir $from/*) printf "%-12s -- %-64s\n" "$(path basename $dir) ..." $(__scriptura_help $dir) end
M functions/__scriptura_new.fishfunctions/__scriptura_new.fish
@@ -1,4 +1,4 @@
-function __scriptura_new +function __scriptura_new --description 'Create new script' argparse --stop-nonopt --move-unknown e/edit -- $argv set --function target $argv[1] set --function remaining $argv[2..]
M functions/__scriptura_run.fishfunctions/__scriptura_run.fish
@@ -1,4 +1,4 @@
-function __scriptura_run --argument-names target +function __scriptura_run --description 'Run a script' --argument-names target if path is --perm exec $target set --export SCRIPTURA_ROOT $SCRIPTURA_ROOT set --export SD (path dirname $target)
M functions/__scriptura_seen_script.fishfunctions/__scriptura_seen_script.fish
@@ -1,4 +1,4 @@
-function __scriptura_seen_script +function __scriptura_seen_script --description 'Check if script name has been seen' test (count $argv) -ne 0 or set --function argv (commandline -xpc)[2..]
M functions/__scriptura_subcommands.fishfunctions/__scriptura_subcommands.fish
@@ -1,3 +1,3 @@
-function __scriptura_subcommands +function __scriptura_subcommands --description 'List available subcommands' path basename $(path filter --type file,dir --perm exec $SCRIPTURA_ROOT/*) end
M functions/__scriptura_which.fishfunctions/__scriptura_which.fish
@@ -1,4 +1,4 @@
-function __scriptura_which --argument-names script_path +function __scriptura_which --description 'Display script path' --argument-names script_path if path is --type file --perm exec $script_path echo $script_path else
M functions/scriptura.fishfunctions/scriptura.fish
@@ -1,4 +1,4 @@
-function scriptura +function scriptura --description 'Manage and execute scripts' set --function valid_subcommands run help new edit which cat if not set --query --function scriptura_root_var