tide/tide_theme/functions/help.fish

57 lines
1.5 KiB
Fish
Raw Normal View History

2020-05-19 06:03:25 +03:00
function tide_help -a subcommand
2020-05-04 07:41:08 +03:00
set -g b (set_color -o)
set -g n (set_color normal)
2020-05-19 06:03:25 +03:00
set -g g (set_color $tide_color_green)
2020-05-04 07:41:08 +03:00
set -g subcommandList \
'configure' \
'uninstall' \
'help'
set -g descriptionList \
'run interactive configuration wizard' \
2020-05-19 06:03:25 +03:00
'uninstall tide theme' \
2020-05-04 07:41:08 +03:00
'print this help message'
if contains $subcommand $subcommandList
if functions -q _help_$subcommand
_help_$subcommand
else
_generic_help_sub $subcommand
end
return 0
end
2020-05-19 06:03:25 +03:00
echo 'Usage: '$g'tide '$n$b'subcommand '$n'[options]'
2020-05-04 07:41:08 +03:00
echo
echo 'Subcommands:'
echo
for sub in $subcommandList
echo -n ' '$b$sub$n
2020-05-17 07:55:51 +03:00
_cursor_right 14
2020-05-04 07:41:08 +03:00
_getDescription $sub
end
echo
echo 'Print help for a specific subcommand:'
echo
2020-05-19 06:03:25 +03:00
echo ' '$g'tide '$n'help '$b'subcommand'$n
2020-05-04 07:41:08 +03:00
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)
2020-05-19 06:03:25 +03:00
echo 'Usage: '$g'tide '$n$b$subcommand$n
2020-05-04 07:41:08 +03:00
echo
string replace $descriptionFirstLetter $upperDescriptionFirstLetter $description
end