2 ############################################################
4 # author: @{SRCPKG_AUTHOR}(@{SRCPKG_AUTHOR_EMAIL})
6 ############################################################
7 # Copyright (C) 2022- Free Software Foundation, Inc.
8 # This configure script is free software; the Free Software
9 # Foundation gives unlimited permission to copy, distribute
11 ############################################################
13 # this file is an demo or template for utility cmd
14 # shell script program.
15 ############################################################
24 # external sourced cmd.
25 #source <extern-script> --load
33 ##############################
34 # section: public comment info
35 ##############################
39 ##############################
40 # section: variable define
41 ##############################
46 # this comment is used for version id auto update.
52 readonly EXAMPLE_VEXT
=
53 readonly EXAMPLE_VER_DATE
=20240201
56 readonly EXAMPLE_PROG
=`basename $0`
58 readonly EXAMPLE_PROG_VERSION
="v${EXAMPLE_V1}.${EXAMPLE_V2}\${EXAMPLE_V3:+\".$EXAMPLE_V3\"}\${EXAMPLE_VEXT:+\"$EXAMPLE_VEXT\"}\${EXAMPLE_VER_DATE:+\"-$EXAMPLE_VER_DATE\"}"
59 EXAMPLE_PROG_VERSION_STR
="`eval echo $EXAMPLE_PROG_VERSION`
60 Copyright (C) @{SRCPKG_YEAR} @{SRCPKG_HOLDER}.
61 This configure script is free software; the Free Software
62 Foundation gives unlimited permission to copy, distribute
65 Writen by @{SRCPKG_AUTHOR}(@{SRCPKG_AUTHOR_EMAIL}).
68 EXAMPLE_PROG_BANNER
="$EXAMPLE_PROG $EXAMPLE_PROG_VERSION_STR"
69 EXAMPLE_PROG_SYNTAX
='Usage: $EXAMPLE_PROG -[${p_shortparam//\|/}]'
70 EXAMPLE_PROG_DESC
=" this file is an demo or template for utility cmd
74 EXAMPLE_PROG_OTHER_DESC
="
77 @ getting helper info:
83 EXAMPLE_USAGE_FMT
='$EXAMPLE_PROG_BANNER
84 ${EXAMPLE_PROG_SYNTAX}
87 $EXAMPLE_PROG_OTHER_DESC'
91 # do not delete this comment, it is used for var define code intert.
93 # args-var-define-begin
99 # @ every paramter desc-str-line start with 'param'.
100 # @ every colum start with '|', and seperated by blanks.
101 # @ '|blank' means a blank line dispalyed in helper.
102 # @ follow with a '' quoated string is the option category string.
103 # @ comment '#' in desc-str is also supported, and can be used to
104 # disable some option have not been implemented.
105 # @ desc-str can be in multiple var. and some of them maybe re-used
106 # for other program by 'source xxx --loadshlib'.
109 |prog $0 'this file is an demo or template for utility cmd shell script program.'
112 # @ PARAMETER DEFINE.
113 # this desc str would be referenced in scripttest, consider about opt name space.
114 # =, param name for opt.
115 # %, var name if this opt is enabled.
116 # &, proc func if opt trigged.
118 |prog $0 'project build util-program.'
120 |blank '[example-category]'
121 |param |- |-- |---subcmd |= |%<subcmd> |&<on_subcmd> |'subcmd demo.'
122 |param |- |-- |---longopt |=<file> |%<longopt> |&<on_longopt> |'long option demo.'
123 |param |- |-- |---shortopt |=<file> |%<shortopt> |&<on_shortopt> |'short option demo.'
129 example_other_desc_str
="
130 |blank 'Version & Helper & Debug:'
131 |param |- |-- |---version |= |%<version> |&<on_version> |'output version info of this program.'
132 |param |- |--help |---help |= |%<help> |&<on_help> |'this helper text doc.'
138 ##############################
139 # section: private function
140 ##############################
145 # fdesc: on subcmd sub-cmd.
154 # fsyntax: on_longopt
155 # fdesc: on longopt sub-cmd.
164 # fsyntax: on_shortopt
165 # fdesc: on shortopt sub-cmd.
174 # fsyntax: on_version
175 # fdesc: on version sub-cmd.
179 eval echo "$EXAMPLE_PROG_VERSION"
186 # fdesc: on help sub-cmd.
190 [[ -z $term_width ]] && term_width
=80
192 helper
="$(opt_helper)"
194 eval EXAMPLE_PROG_SYNTAX
="\"$EXAMPLE_PROG_SYNTAX\""
195 eval echo -ne "\"$EXAMPLE_USAGE_FMT\""
202 ##############################
203 # section: public function
204 ##############################
210 [[ "$@" =~
'--load' ]] && return
215 # prog_opt_dispatch "$@"
216 opt_desc_str_dispatch example_desc_hdr_str
217 opt_desc_str_dispatch example_desc_str
218 opt_desc_str_dispatch example_other_desc_str
221 init_dbglogout
2 testing
20000
222 # set_output_prefix info ""
225 # SRCPKG_DIR="$(pwd)"
226 # TEST_DIR_STR_FMT="$(attr_get catalog::testdir::STR_FMT)"
230 # running action list function for options after init.
231 # the paramter for init will be effact, then execute the
239 if [[ "$@" =~
"--debug" ]]; then
240 declare -g DBGOUTD_OUTPUT
=1
242 # does not need to shift args if the --debug option is not the
243 # first option. it will be ignore in process.
247 if [[ $1 != "--loadshlib" ]]; then
255 ##############################
257 ##############################