docs(usage): add more documentation
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
82cc3737a0
commit
705e2416bc
31
timeout
31
timeout
|
@ -1,8 +1,33 @@
|
|||
#!/bin/sh
|
||||
|
||||
usage() {
|
||||
printf "Usage: %s [-t TIMEOUT] [-c COMMAND]\n\n" "$0"
|
||||
printf "TIMEOUT and COMMAND can be set as env vars.\n"
|
||||
printf "Usage: %s [-v] [-h] [-t TIMEOUT] [-c COMMAND]\n\n" "$0"
|
||||
}
|
||||
|
||||
help() {
|
||||
cat << EOH
|
||||
SYNOPSIS
|
||||
$0 [-v] [-h] [-t TIMEOUT] [-c COMMAND]
|
||||
|
||||
DESCRIPTION
|
||||
|
||||
\`Timeout\` executes a command until the timeout is over.
|
||||
When the command is finished before the timeout then the exit code is \`0\` else it's \`1\`.
|
||||
|
||||
OPTIONS
|
||||
|
||||
-h Show this help
|
||||
|
||||
-v Display the command output (stderr)
|
||||
|
||||
-c COMMAND
|
||||
The command to execute
|
||||
\`COMMAND=... $0\` works to.
|
||||
|
||||
-t TIMEOUT
|
||||
The timeout in seconds (default: 10)
|
||||
\`TIMEOUT=... $0\` works to.
|
||||
EOH
|
||||
}
|
||||
|
||||
on_interrupt() {
|
||||
|
@ -45,7 +70,7 @@ check_pid() {
|
|||
main() {
|
||||
while getopts "ht:c:v" option; do
|
||||
case "${option}" in
|
||||
h) usage; exit 0;;
|
||||
h) help; exit 0;;
|
||||
t) TIMEOUT="$OPTARG";;
|
||||
c) COMMAND="$OPTARG";;
|
||||
v) VERBOSE=1;;
|
||||
|
|
Loading…
Reference in a new issue