all repos — scriptura @ 163c71b4eba9ad76fb28a11a581091ac0177fd07

a corner in $HOME for your scripts

refactor functions

Alan Pearce
commit

163c71b4eba9ad76fb28a11a581091ac0177fd07

parent

62e5f98ddf2b6d02d9b89a70a9bc81933de0a1f8

2 files changed, 36 insertions(+), 35 deletions(-)

changed files
M functions/__scriptura_seen_script.fishfunctions/__scriptura_seen_script.fish
@@ -2,13 +2,13 @@ function __scriptura_seen_script
test (count $argv) -ne 0 or set --function argv (commandline -xpc)[2..] - set --function target $SCRIPTURA_ROOT - argparse --stop-nonopt --move-unknown n/new -- $argv if not set --query argv[1] return 1 end + + set --function target $SCRIPTURA_ROOT for arg in $argv if test "$arg" = --
M functions/scriptura.fishfunctions/scriptura.fish
@@ -46,48 +46,49 @@ break
end end + if test $valid -eq 0 + echo "scriptura: don't know what to do with target \"$argv\"" >&2 + return 1 + end + set --local remaining $argv[(math $valid + 1)..-1] - if test $valid -gt 0 + if set --query _flag_help + __scriptura_help $target + return $status + end - if set --query _flag_help - __scriptura_help $target - return $status - end + if set --query _flag_new + __scriptura_new $target $remaining + return $status + end - if set --query _flag_new - __scriptura_new $target $remaining - return $status - end + if set --query _flag_edit + __scriptura_edit $target + return $status + end + + if set --query _flag_which + __scriptura_which $target $remaining + return $status + end - if set --query _flag_edit - __scriptura_edit $target - return $status - end + if set --query _flag_cat + __scriptura_cat $target + return $status + end - if set --query _flag_which - __scriptura_which $target $remaining + if set --query script + if path is --perm exec $target + $target $remaining return $status - end - - if set --query _flag_cat + else + echo "scriptura: $target is not executable" >&2 __scriptura_cat $target return $status end - - if set --query script - if path is --perm exec $target - $target $remaining - return $status - else - echo "scriptura: $target is not executable" >&2 - __scriptura_cat $target - return $status - end - else if path is --type dir $target; and test (count $remaining) -eq 0 - __scriptura_list $target - return $status - end + else if path is --type dir $target; and test (count $remaining) -eq 0 + __scriptura_list $target + return $status end - echo "scriptura: don't know what to do with target \"$argv\"" >&2 end