File tree Expand file tree Collapse file tree 2 files changed +54
-0
lines changed Expand file tree Collapse file tree 2 files changed +54
-0
lines changed Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ # : TITLE: bash-utils-help
4
+ # : DATE: 2019-04-23
5
+ # : VERSION: 0.1.0
6
+ # : AUTHOR: "Alex Y" <aleksandryackovlev@yandex.ru>
7
+ # : DESCRIPTION: Help information
8
+
9
+ [[ $bashUtilsHelpLoaded ]] && return
10
+
11
+ source bash-utils-env
12
+ source bash-utils-utils
13
+
14
+ # DESCRIPTION: Print the usage information
15
+ # USAGE: usage
16
+ showUsageInfo () {
17
+ printf " %s - %s\n" " $( bash-utils-env scriptName) " " $( bash-utils-env description) "
18
+ cat << - HELP
19
+ USAGE: "$( bash-utils-env usage) "
20
+
21
+ See 'bash-utils help <COMMAND>' to read about a specific subcommand.
22
+ HELP
23
+ }
24
+
25
+ # DESCRIPTION: Print the version information
26
+ # USAGE: version
27
+ showVersionInfo () {
28
+ printf " %s version %s\n" " $( bash-utils-env scriptName) " " $( bash-utils-env version) "
29
+ printf " by %s\n" " $( bash-utils-env author) "
30
+ }
31
+
32
+ # DESCRIPTION: The entry point for the bash-utils-help
33
+ # USAGE: bash-utils-help [COMMAND]
34
+ bash-utils-help () {
35
+ local commandToExec
36
+ commandToExec=" $1 "
37
+ shift
38
+
39
+ if [[ -z $commandToExec ]]; then
40
+ showUsageInfo
41
+ die " $( bash-utils-env successCode) "
42
+ fi
43
+
44
+ case $commandToExec in
45
+ version)
46
+ showVersionInfo
47
+ ;;
48
+ * )
49
+ die " $( bash-utils-env misuseErrorCode) " " An unknown command bash-utils-help " " $commandToExec "
50
+ ;;
51
+ esac
52
+ }
53
+
54
+ bashUtilsHelpLoaded=1
You can’t perform that action at this time.
0 commit comments