mirror of
https://github.com/IlanCosman/tide.git
synced 2024-12-18 17:41:37 +03:00
Convert to meta/sub commands
This commit is contained in:
parent
5f5a18b91d
commit
c85881961b
@ -1,4 +1,4 @@
|
||||
# Created by lean_wizard
|
||||
# Created by lean configure
|
||||
function fish_prompt --description 'Write out the prompt'
|
||||
set -g last_pipestatus $pipestatus
|
||||
set -g last_status $status
|
||||
|
12
functions/lean.fish
Normal file
12
functions/lean.fish
Normal file
@ -0,0 +1,12 @@
|
||||
function lean -a subcommand
|
||||
set -l leanSubCommand "lean_$subcommand"
|
||||
set -l leanCommands 'configure' 'test' 'uninstall' 'help'
|
||||
|
||||
if contains $subcommand $leanCommands
|
||||
source "$__fish_config_dir/lean_theme/functions/$leanSubCommand.fish"
|
||||
$leanSubCommand $argv[2..-1]
|
||||
else
|
||||
lean help
|
||||
end
|
||||
functions -e $leanSubCommand
|
||||
end
|
@ -78,9 +78,9 @@ function lean_install
|
||||
set_color $fish_color_normal
|
||||
|
||||
if _user_confirm_defaultYes 'Configure lean prompt?'
|
||||
lean_wizard
|
||||
lean configure
|
||||
else
|
||||
echo -e '\n''Run lean_wizard to configure your prompt.'
|
||||
echo -e '\n''Run lean configure to configure your prompt.'
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
function lean_wizard
|
||||
function lean_configure
|
||||
if test $COLUMNS -lt 55 || test $LINES -lt 21
|
||||
echo 'Terminal size too small; must be at least 55 x 21'
|
||||
return 1
|
59
lean_theme/functions/lean_help.fish
Normal file
59
lean_theme/functions/lean_help.fish
Normal file
@ -0,0 +1,59 @@
|
||||
function lean_help -a subcommand
|
||||
set -g b (set_color -o)
|
||||
set -g n (set_color normal)
|
||||
set -g g (set_color $lean_color_green)
|
||||
|
||||
set -g subcommandList \
|
||||
'configure' \
|
||||
'test' \
|
||||
'uninstall' \
|
||||
'help'
|
||||
set -g descriptionList \
|
||||
'run interactive configuration wizard' \
|
||||
'perform diagnostics on lean theme' \
|
||||
'uninstall lean theme' \
|
||||
'print this help message'
|
||||
|
||||
if contains $subcommand $subcommandList
|
||||
if functions -q _help_$subcommand
|
||||
_help_$subcommand
|
||||
else
|
||||
_generic_help_sub $subcommand
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
echo 'Usage: '$g'lean '$n$b'subcommand '$n'[options]'
|
||||
echo
|
||||
echo 'Subcommands:'
|
||||
echo
|
||||
for sub in $subcommandList
|
||||
echo -n ' '$b$sub$n
|
||||
printf '\r\033[14C'
|
||||
_getDescription $sub
|
||||
end
|
||||
echo
|
||||
echo 'Print help for a specific subcommand:'
|
||||
echo
|
||||
echo ' '$g'lean '$n'help '$b'subcommand'$n
|
||||
|
||||
set -a rmVars b n g subcommandList descriptionList
|
||||
for var in $rmVars
|
||||
set -e $var
|
||||
end
|
||||
end
|
||||
|
||||
function _getDescription -a subcommand
|
||||
set -l descriptionIndex (contains -i $subcommand $subcommandList)
|
||||
echo $descriptionList[$descriptionIndex]
|
||||
end
|
||||
|
||||
function _generic_help_sub -a subcommand
|
||||
set -l description (_getDescription $subcommand)
|
||||
set -l descriptionFirstLetter (string sub -l 1 $description)
|
||||
set -l upperDescriptionFirstLetter (string upper $descriptionFirstLetter)
|
||||
|
||||
echo 'Usage: '$g'lean '$n$b$subcommand$n
|
||||
echo
|
||||
string replace $descriptionFirstLetter $upperDescriptionFirstLetter $description
|
||||
end
|
@ -1,5 +1,5 @@
|
||||
function lean_uninstall
|
||||
if _user_confirm_defaultNo 'Unininstall lean theme?'
|
||||
if _user_confirm_defaultNo 'Uninstall lean theme?'
|
||||
set -l fishPrompt "$__fish_config_dir/functions/fish_prompt.fish"
|
||||
|
||||
echo 'Uninstalling lean theme...'
|
@ -1,4 +1,4 @@
|
||||
# Created by lean_wizard
|
||||
# Created by lean configure
|
||||
function fake_prompt --description 'Write out the prompt'
|
||||
set -g last_pipestatus $pipestatus
|
||||
set -g last_status $status
|
@ -1,4 +1,4 @@
|
||||
# Created by lean_wizard
|
||||
# Created by lean configure
|
||||
function fish_prompt --description 'Write out the prompt'
|
||||
set -g last_pipestatus $pipestatus
|
||||
set -g last_status $status
|
Loading…
Reference in New Issue
Block a user