Debian Codegraph @

bin/auxilium_test

raw
1 #!/bin/bash
2
3 # shellcheck disable=SC2154
4 # shellcheck disable=SC1091
5
6 if [ -f "../share/auxilium.sh" ]; then
7 . ../share/auxilium.sh
8 else
9 . /usr/share/auxilium/auxilium.sh
10 fi
11
12 auxilium_test() {
13 cat << EOF
14
15 Example code:
16 . /usr/share/auxilium/auxilium.sh
17
18 _opt_function(){
19 echo "Bool function: ${1} ${2}"
20 }
21
22 _pos_function(){
23 _ARG_NAME=$1
24 shift
25 echo "POS function: ${_ARG_NAME} ${@}"
26 }
27
28 auxilium_init $(basename "$0") "Test ARGS PARSE"
29 auxilium_add opt -s b -t opt -c _opt_function -m 'Bool'
30 auxilium_add string -s s -d 'asd' -m 'This is a long String\nFor test this help message'
31 auxilium_add POS2 -t positional -m 'Positional2' -n * -c _pos_function
32
33
34 auxilium_parse \${@}
35 echo "OPT: $_AUXILIUM_ARG_opt"
36 echo "STRING: $_AUXILIUM_ARG_string"
37 echo "POS2: $_AUXILIUM_ARG_pos2"
38
39 auxilium_usage
40
41 Output:
42
43 EOF
44
45 auxilium_init "$(basename "$0")" -m "Test ARGS PARSE"
46 auxilium_add opt -s b -t opt -c _opt_function -m 'Bool'
47 auxilium_add string -s s -d default -m 'This is a long String\nFor test this help message'
48 auxilium_add POS2 -t positional -m 'Positional2' -a -c _pos_function
49
50
51 auxilium_parse "$@"
52 echo "OPT: $AUXILIUM_ARG_opt"
53 echo "STRING: $AUXILIUM_ARG_string"
54 echo "POS2: $AUXILIUM_ARG_pos2"
55
56 auxilium_usage
57
58 }
59
60 _opt_function(){
61 echo "Bool function: ${1} ${2}"
62 }
63
64 _pos_function(){
65 _ARG_NAME=$1
66 shift
67 echo "POS function: ${_ARG_NAME} ${*}"
68 }
69
70 auxilium_test "$@"
71