Refactor how variables are escaped in run
- Add some aliases to run.fish
This commit is contained in:
parent
2c1a20f125
commit
2545c4dd95
17
run
17
run
|
@ -10,6 +10,7 @@ else
|
||||||
end
|
end
|
||||||
|
|
||||||
function main
|
function main
|
||||||
|
alias $run_func_prefix\_default=$run_func_prefix\_help
|
||||||
define_aliases
|
define_aliases
|
||||||
|
|
||||||
for command in $argv
|
for command in $argv
|
||||||
|
@ -26,7 +27,7 @@ end
|
||||||
|
|
||||||
function execute_command -a prefix command
|
function execute_command -a prefix command
|
||||||
set -l args (string split --max 1 $run_arg_delimeter $command)
|
set -l args (string split --max 1 $run_arg_delimeter $command)
|
||||||
set -l func $prefix'_'$args[1]
|
set -l func $prefix\_$args[1]
|
||||||
|
|
||||||
define_default_functions $prefix
|
define_default_functions $prefix
|
||||||
|
|
||||||
|
@ -43,13 +44,13 @@ end
|
||||||
function define_default_functions
|
function define_default_functions
|
||||||
set -g prefix $argv[1]
|
set -g prefix $argv[1]
|
||||||
|
|
||||||
function "$prefix"_commands -d 'List all available commands'
|
function _$prefix\_commands -d 'List all available commands'
|
||||||
set -l names (functions --names | grep $prefix'_')
|
set -l names (functions --names | grep $prefix\_)
|
||||||
|
|
||||||
for name in $names
|
for name in $names
|
||||||
set -l details (functions -D -v $name)
|
set -l details (functions -D -v $name)
|
||||||
set -l description $details[5]
|
set -l description $details[5]
|
||||||
set -l short_name (string replace "$prefix"_ '' $name)
|
set -l short_name (string replace $prefix\_ '' $name)
|
||||||
|
|
||||||
if test (string length $short_name) -ge 8
|
if test (string length $short_name) -ge 8
|
||||||
echo $short_name\t$description
|
echo $short_name\t$description
|
||||||
|
@ -59,13 +60,13 @@ function define_default_functions
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function "$prefix"_help -a command -d 'Print command definition'
|
function $prefix\_help -a command -d 'Print help menu or command definition'
|
||||||
if test -n "$command"
|
if test -n "$command"
|
||||||
functions $prefix'_'$command
|
functions $prefix\_$command
|
||||||
else
|
else
|
||||||
echo 'Here are the available commands:'\n
|
echo 'Here are the available commands:'\n
|
||||||
"$prefix"_commands
|
_$prefix\_commands
|
||||||
echo \n"To see a command's definition and description do `run help$run_arg_delimeter{command}`"
|
echo \n"To see a command's definition do `run help$run_arg_delimeter{command}`"
|
||||||
echo "To see a subcommand group's help menu do `run {command}$run_arg_delimeter""help`"
|
echo "To see a subcommand group's help menu do `run {command}$run_arg_delimeter""help`"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
8
run.fish
8
run.fish
|
@ -8,7 +8,13 @@
|
||||||
set -g run_arg_delimeter ':'
|
set -g run_arg_delimeter ':'
|
||||||
|
|
||||||
function define_aliases
|
function define_aliases
|
||||||
alias run_default='run_install'
|
alias run_default='run_help'
|
||||||
|
|
||||||
|
alias run_i='run_install'
|
||||||
|
alias run_l='run_lint'
|
||||||
|
alias run_f='run_format'
|
||||||
|
alias run_h='run_hello'
|
||||||
|
alias hello_w='hello_world'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue