Cleanup default command logic and remove define_aliases hook

This commit is contained in:
mitchell 2020-10-27 11:55:51 -04:00
parent 2545c4dd95
commit e45d11220c
2 changed files with 26 additions and 26 deletions

24
run
View file

@ -10,18 +10,12 @@ else
end
function main
alias $run_func_prefix\_default=$run_func_prefix\_help
define_aliases
for command in $argv
set -l last_status $status
test $last_status -gt 0; and exit $last_status
execute_command $run_func_prefix $command
and execute_command $run_func_prefix $command
end
if test -z "$argv"
execute_command $run_func_prefix default
and if test -z "$argv"
execute_command $run_func_prefix
end
end
@ -31,10 +25,10 @@ function execute_command -a prefix command
define_default_functions $prefix
if functions -q $func
$func $args[2]
else if test -z "$command"
if test -z "$command"
execute_command $prefix default
else if functions -q $func
$func $args[2]
else
echo "$prefix command '$command' does not exist"
exit 1
@ -70,6 +64,12 @@ function define_default_functions
echo "To see a subcommand group's help menu do `run {command}$run_arg_delimeter""help`"
end
end
if not functions -q $prefix\_default
function $prefix\_default -a arg -d 'Alias for help command'
$prefix\_help $arg
end
end
end
main $argv