Debian Codegraph @

release_tools/handle_ltversions.sh

raw symbols SCIP
1 #!/bin/bash
2
3 # Created by argbash-init v2.5.0
4 # ARG_POSITIONAL_SINGLE([strategy],[<strategy's help message goes here>],[])
5 # ARGBASH_SET_DELIM([ ])
6 # ARGBASH_SET_INDENT([ ])
7 # ARG_OPTION_STACKING([none])
8 # ARG_RESTRICT_VALUES([none])
9 # ARG_TYPE_GROUP_SET([strategy],[STRATEGY],[strategy],[bugfix,backwards_compatible,breaking_change])
10 # ARG_HELP([Increment Libtool library versions in configure scripts and check that it works.])
11 # DEFINE_SCRIPT_DIR([])
12 # ARGBASH_GO()
13 # needed because of Argbash --> m4_ignore([
14 ### START OF CODE GENERATED BY Argbash v2.5.0 one line above ###
15 # Argbash is a bash code generator used to get arguments parsing right.
16 # Argbash is FREE SOFTWARE, see https://argbash.io for more info
17
18 die()
19 {
20 local _ret=$2
21 test -n "$_ret" || _ret=1
22 test "$_PRINT_HELP" = yes && print_help >&2
23 echo "$1" >&2
24 exit ${_ret}
25 }
26
27 # validators
28 strategy()
29 {
30 local _allowed=("bugfix" "backwards_compatible" "breaking_change")
31 local _seeking="$1"
32 for element in "${_allowed[@]}"
33 do
34 test "$element" = "$_seeking" && echo "$element" && return 0
35 done
36 die "Value '$_seeking' (of argument '$2') doesn't match the list of allowed values: 'bugfix', 'backwards_compatible' and 'breaking_change'" 4
37 }
38
39 # THE DEFAULTS INITIALIZATION - POSITIONALS
40 _positionals=()
41 # THE DEFAULTS INITIALIZATION - OPTIONALS
42
43 print_help ()
44 {
45 printf "%s\n" "Increment Libtool library versions in configure scripts and check that it works."
46 printf 'Usage: %s [-h|--help] <strategy>\n' "$0"
47 printf "\t%s\n" "<strategy>: <strategy's help message goes here>"
48 printf "\t%s\n" "-h,--help: Prints help"
49 echo
50 echo 'Short options stacking mode is not supported.'
51 }
52
53 parse_commandline ()
54 {
55 while test $# -gt 0
56 do
57 _key="$1"
58 case "$_key" in
59 -h|--help)
60 print_help
61 exit 0
62 ;;
63 *)
64 _positionals+=("$1")
65 ;;
66 esac
67 shift
68 done
69 }
70
71
72 handle_passed_args_count ()
73 {
74 _required_args_string="'strategy'"
75 test ${#_positionals[@]} -lt 1 && _PRINT_HELP=yes die "FATAL ERROR: Not enough positional arguments - we require exactly 1 (namely: $_required_args_string), but got only ${#_positionals[@]}." 1
76 test ${#_positionals[@]} -gt 1 && _PRINT_HELP=yes die "FATAL ERROR: There were spurious positional arguments --- we expect exactly 1 (namely: $_required_args_string), but got ${#_positionals[@]} (the last one was: '${_positionals[*]: -1}')." 1
77 }
78
79 assign_positional_args ()
80 {
81 _positional_names=('_arg_strategy' )
82
83 for (( ii = 0; ii < ${#_positionals[@]}; ii++))
84 do
85 eval "${_positional_names[ii]}=\${_positionals[ii]}" || die "Error during argument parsing, possibly an Argbash bug." 1
86 done
87 }
88
89 parse_commandline "$@"
90 handle_passed_args_count
91 assign_positional_args
92
93 # OTHER STUFF GENERATED BY Argbash
94 script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" || die "Couldn't determine the script's running directory, which probably matters, bailing out" 2
95 # Validation of values
96 _arg_strategy="$(strategy "$_arg_strategy" "strategy")" || exit 1
97
98
99 ### END OF CODE GENERATED BY Argbash (sortof) ### ])
100 # [ <-- needed because of Argbash
101
102
103 . "$script_dir/release.sh"
104
105 increment_ltversions "$_arg_strategy"
106
107 # ] <-- needed because of Argbash