Last active
February 1, 2023 12:37
-
-
Save ksuderman/c92cd5e86c70c2018099913587f29c0a to your computer and use it in GitHub Desktop.
Print simple help with ANSI highlighting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ANSI color codes for the console. | |
reset="\033[0m" | |
bold="\033[1m" | |
ital="\033[3m" # does not work on OS X | |
# Function used to highlight text. | |
function hi() { | |
echo -e "$bold$@$reset" | |
} | |
function help() { | |
cat | less -RX << EOF | |
$(hi USAGE) | |
$(basename $(realpath $0)) [COMMAND] [OPTIONS] | |
$(hi SYNOPSIS) | |
Provide a short description here | |
$(hi COMMANDS) | |
$(hi command1) Do something | |
$(hi command2) Do something else | |
$(hi OPTIONS) | |
$(hi -o|--option) flag me | |
$(hi EXAMPLES) | |
EOF | |
} | |
if [[ $# == 0 ]] ; then | |
help | |
exit | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment