-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f401c24
commit 753e7e6
Showing
2 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/usr/bin/env bash | ||
|
||
#: TITLE: bash-utils-help | ||
#: DATE: 2019-04-23 | ||
#: VERSION: 0.1.0 | ||
#: AUTHOR: "Alex Y" <aleksandryackovlev@yandex.ru> | ||
#: DESCRIPTION: Help information | ||
|
||
[[ $bashUtilsHelpLoaded ]] && return | ||
|
||
source bash-utils-env | ||
source bash-utils-utils | ||
|
||
# DESCRIPTION: Print the usage information | ||
# USAGE: usage | ||
showUsageInfo() { | ||
printf "%s - %s\n" "$(bash-utils-env scriptName)" "$(bash-utils-env description)" | ||
cat <<- HELP | ||
USAGE: "$(bash-utils-env usage)" | ||
See 'bash-utils help <COMMAND>' to read about a specific subcommand. | ||
HELP | ||
} | ||
|
||
# DESCRIPTION: Print the version information | ||
# USAGE: version | ||
showVersionInfo() { | ||
printf "%s version %s\n" "$(bash-utils-env scriptName)" "$(bash-utils-env version)" | ||
printf "by %s\n" "$(bash-utils-env author)" | ||
} | ||
|
||
# DESCRIPTION: The entry point for the bash-utils-help | ||
# USAGE: bash-utils-help [COMMAND] | ||
bash-utils-help() { | ||
local commandToExec | ||
commandToExec="$1" | ||
shift | ||
|
||
if [[ -z $commandToExec ]]; then | ||
showUsageInfo | ||
die "$(bash-utils-env successCode)" | ||
fi | ||
|
||
case $commandToExec in | ||
version) | ||
showVersionInfo | ||
;; | ||
*) | ||
die "$(bash-utils-env misuseErrorCode)" "An unknown command bash-utils-help ""$commandToExec" | ||
;; | ||
esac | ||
} | ||
|
||
bashUtilsHelpLoaded=1 |
Empty file.