help output

This commit is contained in:
Michael 2017-06-06 06:40:41 +10:00
parent 1a5360551e
commit 51ebc2570d
1 changed files with 36 additions and 5 deletions

View File

@ -224,10 +224,17 @@ function explain() {
>&2 echo -e Warning:$_file:$_line_no:$_message
}
# Parse command-line optins
function show_help() {
# Parse command-line optins...
function show_usage() {
cat << EOF
usage: mdcheckr [ -h | --help | -v | --version ] FILE ..
EOF
}
function show_help() {
show_usage
cat << EOF
usage: mdcheckr [ -h ] FILE ..
A testing tool to detect quality problems with your Markdown documentation.
@ -248,8 +255,25 @@ function show_version() {
VERSION="1.0"
OPTIND=1
VERBOSITY=3
while getopts hv opt; do
while getopts "hv-:" opt; do
case $opt in
-)
case "${OPTARG}" in
help)
show_help
exit 0
;;
version)
show_version
exit 0
;;
*)
echo "$0: Illegal option -- ${OPTARG}" >&2
show_usage >&2
exit 1
;;
esac
;;
h)
show_help
exit 0
@ -259,13 +283,20 @@ while getopts hv opt; do
exit 0
;;
*)
show_help >&2
show_usage >&2
exit 1
;;
esac
done
shift "$((OPTIND-1))"
# Require at least one filename to be specified
if [ "$#" -lt 1 ]; then
echo "$0: Missing file operand" >&2
show_usage >&2
fi
# Explicitly check for each dependency
for i in which pandoc xmllint curl; do which $i > /dev/null 2> /dev/null || (
>&2 echo "The tool '$i' is required by mdcheckr, but is not in your \$PATH."