tide/lean_theme/functions/help.fish
2020-05-16 21:55:51 -07:00

57 lines
1.5 KiB
Fish

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' \
'uninstall' \
'help'
set -g descriptionList \
'run interactive configuration wizard' \
'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
_cursor_right 14
_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