Use error() and warning() functions in options parsing
This commit is contained in:
parent
3e2bbe8de5
commit
1c4b68f571
26
shellpki
26
shellpki
|
@ -278,8 +278,7 @@ create() {
|
||||||
fi
|
fi
|
||||||
shift
|
shift
|
||||||
else
|
else
|
||||||
printf 'ERROR: "--csr-file" requires a non-empty option argument.\n' >&2
|
error "Argument error: \`--csr-file' requires a value"
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
--file=?*|--csr-file=?*)
|
--file=?*|--csr-file=?*)
|
||||||
|
@ -292,8 +291,7 @@ create() {
|
||||||
;;
|
;;
|
||||||
--file=|--csr-file=)
|
--file=|--csr-file=)
|
||||||
# csr-file options, without value
|
# csr-file options, without value
|
||||||
printf 'ERROR: "--csr-file" requires a non-empty option argument.\n' >&2
|
error "Argument error: \`--csr-file' requires a value"
|
||||||
exit 1
|
|
||||||
;;
|
;;
|
||||||
-p|--password)
|
-p|--password)
|
||||||
ask_pass=1
|
ask_pass=1
|
||||||
|
@ -307,8 +305,7 @@ create() {
|
||||||
fi
|
fi
|
||||||
shift
|
shift
|
||||||
else
|
else
|
||||||
printf 'ERROR: "--password-file" requires a non-empty option argument.\n' >&2
|
error "Argument error: \`--password-file' requires a value"
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
--password-file=?*)
|
--password-file=?*)
|
||||||
|
@ -320,8 +317,7 @@ create() {
|
||||||
;;
|
;;
|
||||||
--password-file=)
|
--password-file=)
|
||||||
# password-file options, without value
|
# password-file options, without value
|
||||||
printf 'ERROR: "--password-file" requires a non-empty option argument.\n' >&2
|
error "Argument error: \`--password-file' requires a value"
|
||||||
exit 1
|
|
||||||
;;
|
;;
|
||||||
--days)
|
--days)
|
||||||
# days option, with value separated by space
|
# days option, with value separated by space
|
||||||
|
@ -329,8 +325,7 @@ create() {
|
||||||
days=${2}
|
days=${2}
|
||||||
shift
|
shift
|
||||||
else
|
else
|
||||||
printf 'ERROR: "--days" requires a non-empty option argument.\n' >&2
|
error "Argument error: \`--days' requires a value"
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
--days=?*)
|
--days=?*)
|
||||||
|
@ -339,8 +334,7 @@ create() {
|
||||||
;;
|
;;
|
||||||
--days=)
|
--days=)
|
||||||
# days options, without value
|
# days options, without value
|
||||||
printf 'ERROR: "--days" requires a non-empty option argument.\n' >&2
|
error "Argument error: \`--days' requires a value"
|
||||||
exit 1
|
|
||||||
;;
|
;;
|
||||||
--end-date)
|
--end-date)
|
||||||
# end-date option, with value separated by space
|
# end-date option, with value separated by space
|
||||||
|
@ -348,8 +342,7 @@ create() {
|
||||||
end_date=${2}
|
end_date=${2}
|
||||||
shift
|
shift
|
||||||
else
|
else
|
||||||
printf 'ERROR: "--end-date" requires a non-empty option argument.\n' >&2
|
error "Argument error: \`--end-date' requires a value"
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
--end-date=?*)
|
--end-date=?*)
|
||||||
|
@ -358,8 +351,7 @@ create() {
|
||||||
;;
|
;;
|
||||||
--end-date=)
|
--end-date=)
|
||||||
# end-date options, without value
|
# end-date options, without value
|
||||||
printf 'ERROR: "--end-date" requires a non-empty option argument.\n' >&2
|
error "Argument error: \`--end-date' requires a value"
|
||||||
exit 1
|
|
||||||
;;
|
;;
|
||||||
--non-interactive)
|
--non-interactive)
|
||||||
non_interactive=1
|
non_interactive=1
|
||||||
|
@ -371,7 +363,7 @@ create() {
|
||||||
;;
|
;;
|
||||||
-?*)
|
-?*)
|
||||||
# ignore unknown options
|
# ignore unknown options
|
||||||
printf 'WARN: Unknown option (ignored): %s\n' "$1" >&2
|
warning "Warning: unknown option (ignored): \`$1'"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
# Default case: If no more options then break out of the loop.
|
# Default case: If no more options then break out of the loop.
|
||||||
|
|
Loading…
Reference in a new issue