Added help menu
This commit is contained in:
parent
b842e7c4f6
commit
197e637da1
@ -3,9 +3,15 @@
|
|||||||
# "Import" our needed functions from our library
|
# "Import" our needed functions from our library
|
||||||
LIBRARY_PATH="/usr/local/lib/Custom-Scripts"
|
LIBRARY_PATH="/usr/local/lib/Custom-Scripts"
|
||||||
# shellcheck source=/usr/local/lib/
|
# shellcheck source=/usr/local/lib/
|
||||||
source "${LIBRARY_PATH}/Logging-RGB.bash" || echo "Unable to source Logging-RGB.bash at ${LIBRARY_PATH}"
|
if ! source "${LIBRARY_PATH}/Logging-RGB.bash"; then
|
||||||
|
echo "Unable to source Logging-RGB.bash at ${LIBRARY_PATH}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
# shellcheck source=/usr/local/lib/
|
# shellcheck source=/usr/local/lib/
|
||||||
source "${LIBRARY_PATH}/Trim.bash" || log "error" "Unable to source Trim.bash at ${LIBRARY_PATH}"
|
if ! source "${LIBRARY_PATH}/Trim.bash"; then
|
||||||
|
log "error" "Unable to source Trim.bash at ${LIBRARY_PATH}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Tmp file used because most distros have this dir exist in RAM, use PID of our process to write to
|
# Tmp file used because most distros have this dir exist in RAM, use PID of our process to write to
|
||||||
TEMP_FILE="/tmp/$$"
|
TEMP_FILE="/tmp/$$"
|
||||||
@ -237,6 +243,18 @@ templater() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
arg_required() {
|
||||||
|
echo_rgb "${1}" 255 183 0
|
||||||
|
}
|
||||||
|
|
||||||
|
arg_optional(){
|
||||||
|
echo_rgb "${1}" 117 255 255
|
||||||
|
}
|
||||||
|
|
||||||
|
arg_description(){
|
||||||
|
echo_rgb "${@}" 220 190 255
|
||||||
|
}
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
# Print out usage instructions for the local script
|
# Print out usage instructions for the local script
|
||||||
#
|
#
|
||||||
@ -250,13 +268,37 @@ usage() {
|
|||||||
# Yes
|
# Yes
|
||||||
#
|
#
|
||||||
printf "Usage: %s\n" \
|
printf "Usage: %s\n" \
|
||||||
"$(basename ${0}) -i \"this is some input\" -t \"this is some more example input\"
|
"$(basename ${0}) [OPTIONS]
|
||||||
--input <string> | -i <string>
|
$(arg_required "REQUIRED")
|
||||||
|
$(arg_optional "OPTIONAL")
|
||||||
|
|
||||||
|
$(arg_required "--template-file") <templateFile: string> | $(arg_required "-t") <templateFile: string>
|
||||||
|
$(arg_description "A template file to parse and apply rules for
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
--input \"this is an example input\"
|
--template-file example.tmpl")
|
||||||
--test <string> | -t <string>
|
|
||||||
|
$(arg_optional "--contents-dir") <contentsDirectory: string> | $(arg_optional "-c") <contentsDirectory: string>
|
||||||
|
$(arg_description "The files that contain contents read by the templates.
|
||||||
|
|
||||||
|
By default this is set to ~/.contents/ if unset, to set via variable you can either use this argument or pass
|
||||||
|
export CONTENTS_DIRECTORY=\`your contents directory\`
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
--test \"this is more example input\""
|
--contents-dir ~/Desktop/contents")
|
||||||
|
|
||||||
|
$(arg_optional "--output-to") <outputFile: string> | $(arg_optional "-o") <outputFile: string>
|
||||||
|
$(arg_description "The file to output the applied template to, this can be set within a template, but can be overriden with this option
|
||||||
|
|
||||||
|
Example:
|
||||||
|
--output-to myfile.out")
|
||||||
|
|
||||||
|
$(arg_optional "--no-exit") | $(arg_optional "-n")
|
||||||
|
$(arg_description "Do not exit on any errors, continue executing
|
||||||
|
|
||||||
|
Example:
|
||||||
|
--no-exit")"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
|
Loading…
Reference in New Issue
Block a user