tide/tide_theme/functions/help.fish

58 lines
1.7 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-20 00:10:19 +03:00
printf '%s\n' 'Usage: '$g'tide '$n$b'subcommand '$n'[options]'
printf '%s\n'
printf '%s\n' 'Subcommands:'
printf '%s\n'
2020-05-04 07:41:08 +03:00
for sub in $subcommandList
2020-05-20 00:10:19 +03:00
printf '%s' ' '$b$sub$n
2020-05-19 06:28:17 +03:00
printf '%b' '\r'
2020-05-17 07:55:51 +03:00
_cursor_right 14
2020-05-04 07:41:08 +03:00
_getDescription $sub
end
2020-05-20 00:10:19 +03:00
printf '%s\n'
printf '%s\n' 'Print help for a specific subcommand:'
printf '%s\n'
printf '%s\n' ' '$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)
2020-05-20 00:10:19 +03:00
printf '%s\n' $descriptionList[$descriptionIndex]
2020-05-04 07:41:08 +03:00
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-20 00:10:19 +03:00
printf '%s\n' 'Usage: '$g'tide '$n$b$subcommand$n
printf '%s\n'
2020-05-04 07:41:08 +03:00
string replace $descriptionFirstLetter $upperDescriptionFirstLetter $description
end