-
Notifications
You must be signed in to change notification settings - Fork 0
/
advanced.bash
executable file
·66 lines (53 loc) · 1.19 KB
/
advanced.bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
# Copyright 2023 Liu Dong <liudng@hotmail.com>. All rights reserved.
# Use of this source code is governed by Apache License
# that can be found in the LICENSE file.
# The dev execution file path
declare -gr dev_global_self="$(realpath $0)"
# The dev execution base directory
declare -gr dev_global_base="$(dirname $dev_global_self)"
# Include dev-core
. $dev_global_base/lib/dev-core.bash
#
# Declare custom global variables here.
#
#
# Write your own tasks here.
#
dev_task_main() {
echo "This is a sample bash script."
echo "demo_key = $demo_key"
echo "Custom arguments: $@"
echo "dev_global_base: $dev_global_base"
}
dev_help_usage() {
#
# Add custom help here.
#
echo " --demo=VALUE Example key and value"
}
dev_optional_arguments() {
#
# Insert custom optional arguments here.
#
case "$dev_arg_key" in
--demo)
declare -gr demo_key="$dev_arg_val"
;;
# Nothing was matched.
*)
echo "Optional argument not found: $1" >&2
exit
;;
esac
}
dev_validation() {
#
# Write your own validations here.
#
if [[ -z $demo_key ]]; then
echo "Error: --demo is required." >&2
return 1
fi
}
dev_main $@