refactor functions
1 file changed, 34 insertions(+), 33 deletions(-)
changed files
M functions/scriptura.fish → functions/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