From ee09a753c0b3d27b7f6e54192d0a30737c55484b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20T=C3=BD=C4=8D?= Date: Sun, 3 Sep 2017 18:50:35 +0200 Subject: [PATCH] Released 2.5.0 --- ChangeLog | 4 +- bin/argbash | 4 +- bin/argbash-1to2 | 4 +- bin/argbash-init | 4 +- doc/conf.py | 2 +- resources/Makefile | 2 +- resources/examples/minimal-raw.m4 | 2 +- resources/examples/minimal.m4 | 2 +- resources/examples/minimal.sh | 178 --------------------------- resources/examples/simple-parsing.sh | 2 +- resources/examples/simple-wrapper.sh | 2 +- resources/examples/simple.sh | 2 +- src/version | 2 +- 13 files changed, 16 insertions(+), 194 deletions(-) delete mode 100755 resources/examples/minimal.sh diff --git a/ChangeLog b/ChangeLog index bbf0260..1765c04 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,4 @@ -2.5.0 (TBA) +2.5.0 (2017-09-03) ------------------ New features: @@ -16,7 +16,7 @@ Bugfixes: * Improved feedback when users provide invalid input (fixed #8, #9). * The underlying code has been cleaned and distributed into multiple files. * Fixed `m4_list_indices` to be consistent with `m4_list_nth`. -* Improved handling of typed arguments. +* Much-improved handling of typed arguments (fixed #25, #26). * Improved documentation. Thanks to [Bianca Tamayo](https://github.com/btamayo)! 2.4.0 (2017-04-08) diff --git a/bin/argbash b/bin/argbash index 3c7a332..aa9a87e 100755 --- a/bin/argbash +++ b/bin/argbash @@ -1,6 +1,6 @@ #!/bin/bash -version=2.4.1a +version=2.5.0 # DEFINE_SCRIPT_DIR() # ARG_POSITIONAL_SINGLE([input],[The input template file (pass '-' for stdout)]) # ARG_OPTIONAL_SINGLE([output],[o],[Name of the output file (pass '-' for stdout)],[-]) @@ -14,7 +14,7 @@ version=2.4.1a # ARGBASH_GO() # needed because of Argbash --> m4_ignore([ -### START OF CODE GENERATED BY Argbash v2.4.1a one line above ### +### START OF CODE GENERATED BY Argbash v2.5.0 one line above ### # Argbash is a bash code generator used to get arguments parsing right. # Argbash is FREE SOFTWARE, see https://argbash.io for more info diff --git a/bin/argbash-1to2 b/bin/argbash-1to2 index cafea52..88e1a89 100755 --- a/bin/argbash-1to2 +++ b/bin/argbash-1to2 @@ -1,6 +1,6 @@ #!/bin/bash -version=2.4.1a +version=2.5.0 # ARG_POSITIONAL_INF([input],[The input file to transform],[1]) # ARG_OPTIONAL_SINGLE([output],[o],[Name of the output file (pass '-' for stdout and empty string for the same as input file)],[""]) # ARG_VERSION([echo "argbash-1to2 v$version"]) @@ -8,7 +8,7 @@ version=2.4.1a # ARGBASH_GO() # needed because of Argbash --> m4_ignore([ -### START OF CODE GENERATED BY Argbash v2.4.1a one line above ### +### START OF CODE GENERATED BY Argbash v2.5.0 one line above ### # Argbash is a bash code generator used to get arguments parsing right. # Argbash is FREE SOFTWARE, see https://argbash.io for more info diff --git a/bin/argbash-init b/bin/argbash-init index 1ffda7d..d124866 100755 --- a/bin/argbash-init +++ b/bin/argbash-init @@ -1,6 +1,6 @@ #!/bin/bash -version=2.4.1a +version=2.5.0 # ARG_POSITIONAL_SINGLE([output],[Name of the output template],["-"]) # ARG_OPTIONAL_INCREMENTAL([separate],[s],[Separate the parsing logic (specify two times for complete separation)]) # ARG_OPTIONAL_BOOLEAN([hints],[],[Whether to write hints to the script template]) @@ -15,7 +15,7 @@ version=2.4.1a # ARGBASH_GO() # needed because of Argbash --> m4_ignore([ -### START OF CODE GENERATED BY Argbash v2.4.1a one line above ### +### START OF CODE GENERATED BY Argbash v2.5.0 one line above ### # Argbash is a bash code generator used to get arguments parsing right. # Argbash is FREE SOFTWARE, see https://argbash.io for more info diff --git a/doc/conf.py b/doc/conf.py index 3ac2d57..3409bb3 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -55,7 +55,7 @@ # General information about the project. project = 'Argbash' -copyright = u'2015, Matěj Týč' +copyright = u'2015--2017, Matěj Týč' author = u'Matěj Týč' # The version info for the project you're documenting, acts as replacement for diff --git a/resources/Makefile b/resources/Makefile index f11fe2d..d907f68 100644 --- a/resources/Makefile +++ b/resources/Makefile @@ -156,7 +156,7 @@ version: release: version $(GENPARSE) $(ARGBASH_TO) examples check sed -i "1s/([-0-9]+)/($$(date -I))/" $(CHANGELOG) - cd ../doc && make clean && make html && make clean-tmp + cd ../doc && $(MAKE) clean && $(MAKE) html && $(MAKE) clean-tmp tag: git tag $(shell cat ../src/version) -s -m 'Version release' master diff --git a/resources/examples/minimal-raw.m4 b/resources/examples/minimal-raw.m4 index c4f9e51..427784b 100755 --- a/resources/examples/minimal-raw.m4 +++ b/resources/examples/minimal-raw.m4 @@ -2,7 +2,7 @@ # m4_ignore( echo "This is just a script template, not the script (yet) - pass it to 'argbash' to fix this." >&2 -exit 11 #)Created by argbash-init v2.4.1a +exit 11 #)Created by argbash-init v2.5.0 # ARG_OPTIONAL_SINGLE([option], , []) # ARG_OPTIONAL_BOOLEAN([print], , []) # ARG_POSITIONAL_SINGLE([positional-arg], [], ) diff --git a/resources/examples/minimal.m4 b/resources/examples/minimal.m4 index 525bb7d..12a3bfe 100644 --- a/resources/examples/minimal.m4 +++ b/resources/examples/minimal.m4 @@ -2,7 +2,7 @@ # m4_ignore( echo "This is just a script template, not the script (yet) - pass it to 'argbash' to fix this." >&2 -exit 11 #)Created by argbash-init v2.4.1a +exit 11 #)Created by argbash-init v2.5.0 # ARG_OPTIONAL_SINGLE([option], o, [A option with short and long flags and default], [boo]) # ARG_OPTIONAL_BOOLEAN([print], , [A boolean option with long flag (and implicit default: off)]) # ARG_POSITIONAL_SINGLE([positional-arg], [Positional arg description], ) diff --git a/resources/examples/minimal.sh b/resources/examples/minimal.sh deleted file mode 100755 index 17916f4..0000000 --- a/resources/examples/minimal.sh +++ /dev/null @@ -1,178 +0,0 @@ -#!/bin/bash - -# Created by argbash-init v2.4.1a -# ARG_OPTIONAL_SINGLE([option],[o],[A option with short and long flags and default],[boo]) -# ARG_OPTIONAL_BOOLEAN([print],[],[A boolean option with long flag (and implicit default: off)]) -# ARG_POSITIONAL_SINGLE([positional-arg],[Positional arg description],[]) -# ARG_HELP([This is a minimal demo of Argbash potential]) -# ARG_VERSION([echo $0 v0.1]) -# ARGBASH_SET_INDENT([ ]) -# ARGBASH_GO() -# needed because of Argbash --> m4_ignore([ -### START OF CODE GENERATED BY Argbash v2.4.1a one line above ### -# Argbash is a bash code generator used to get arguments parsing right. -# Argbash is FREE SOFTWARE, see https://argbash.io for more info - -# When called, the process ends. -# Args: -# $1: The exit message (print to stderr) -# $2: The exit code (default is 1) -# if env var _PRINT_HELP is set to 'yes', the usage is print to stderr (prior to ) -# Example: -# test -f "$_arg_infile" || _PRINT_HELP=yes die "Can't continue, have to supply file as an argument, got '$_arg_infile'" 4 -die() -{ - local _ret=$2 - test -n "$_ret" || _ret=1 - test "$_PRINT_HELP" = yes && print_help >&2 - echo "$1" >&2 - exit ${_ret} -} - -# Function that evaluates whether a value passed to it -# begins by a character that is a short option of an argument -# the script knows about -begins_with_short_option() -{ - local first_option all_short_options - all_short_options='ohv' - first_option="${1:0:1}" - test "$all_short_options" = "${all_short_options/$first_option/}" && return 1 || return 0 -} - - - -# THE DEFAULTS INITIALIZATION - POSITIONALS -# The positional args array has to be reset before the parsing, because it may already be defined -# - for example if this script is sourced by an argbash-powered script. -_positionals=() -# THE DEFAULTS INITIALIZATION - OPTIONALS -_arg_option="boo" -_arg_print=off - -# Function that prints general usage of the script. -# This is useful if users asks for it, or if there is an argument parsing error (unexpected / spurious arguments) -# and it makes sense to remind the user how the script is supposed to be called. -print_help () -{ - printf "%s\n" "This is a minimal demo of Argbash potential" - printf 'Usage: %s [-o|--option ] [--(no-)print] [-h|--help] [-v|--version] \n' "$0" - printf "\t%s\n" ": Positional arg description" - printf "\t%s\n" "-o,--option: A option with short and long flags and default (default: '"boo"')" - printf "\t%s\n" "--print,--no-print: A boolean option with long flag (and implicit default: off) (off by default)" - printf "\t%s\n" "-h,--help: Prints help" - printf "\t%s\n" "-v,--version: Prints version" -} - -# The parsing of the command-line -parse_commandline () -{ - while test $# -gt 0 - do - _key="$1" - case "$_key" in - # We support whitespace as a delimiter between option argument and its value. - # Therefore, we expect the --option or -o value. - # so we watch for --option and -o. - # Since we know that we got the long or short option, - # we just reach out for the next argument to get the value. - -o|--option) - test $# -lt 2 && die "Missing value for the optional argument '$_key'." 1 - _arg_option="$2" - shift - ;; - # We support the = as a delimiter between option argument and its value. - # Therefore, we expect --option=value, so we watch for --option=* - # For whatever we get, we strip '--option=' using the ${var##--option} notation - # to get the argument value - --option=*) - _arg_option="${_key##--option=}" - ;; - # We support getopts-style short arguments clustering, - # so as -o accepts value, we allow it to be appended to it, so we watch for -o* - # and we strip the leading -o from the argument string using the ${var##-o} notation. - -o*) - _arg_option="${_key##-o}" - ;; - # The print argurment doesn't accept a value, - # we expect the --print, so we watch for it. - --no-print|--print) - _arg_print="on" - test "${1:0:5}" = "--no-" && _arg_print="off" - ;; - # See the comment of option --print to see what's going on here - -h|--help) - print_help - exit 0 - ;; - # We support getopts-style short arguments clustering, - # so as -h doesn't accepts value, other short options may appended to it, so we watch for -h*. - # After strip the leading -h from the argument, - # we have to make sure that the first character coresponds to a short option. - -h*) - print_help - exit 0 - ;; - # See the comment of option --print to see what's going on here - -v|--version) - echo $0 v0.1 - exit 0 - ;; - # See the comment of option -h to see what's going on here - -v*) - echo $0 v0.1 - exit 0 - ;; - *) - _positionals+=("$1") - ;; - esac - shift - done -} - - -# Check that we receive expected amount positional arguments. -# Return 0 if everything is OK, 1 if we have too little arguments -# and 2 if we have too much arguments -handle_passed_args_count () -{ - _required_args_string="'positional-arg'" - 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 - 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 -} - -# Take arguments that we have received, and save them in variables of given names. -# The 'eval' command is needed as the name of target variable is saved into another variable. -assign_positional_args () -{ - # We have an array of variables to which we want to save positional args values. - # This array is able to hold array elements as targets. - _positional_names=('_arg_positional_arg' ) - - for (( ii = 0; ii < ${#_positionals[@]}; ii++)) - do - eval "${_positional_names[ii]}=\${_positionals[ii]}" || die "Error during argument parsing, possibly an Argbash bug." 1 - done -} - -# Now call all the functions defined above that are needed to get the job done -parse_commandline "$@" -handle_passed_args_count -assign_positional_args - -# OTHER STUFF GENERATED BY Argbash - -### END OF CODE GENERATED BY Argbash (sortof) ### ]) -# [ <-- needed because of Argbash - - -if [ "$_arg_print" = on ] -then - echo "Positional arg value: '$_arg_positional_arg'" - echo "Optional arg '--option' value: '$_arg_option'" -else - echo "Not telling anything, print not requested" -fi - -# ] <-- needed because of Argbash diff --git a/resources/examples/simple-parsing.sh b/resources/examples/simple-parsing.sh index 971b9c0..c05bfa3 100755 --- a/resources/examples/simple-parsing.sh +++ b/resources/examples/simple-parsing.sh @@ -8,7 +8,7 @@ # ARGBASH_SET_INDENT([ ]) # ARGBASH_GO() # needed because of Argbash --> m4_ignore([ -### START OF CODE GENERATED BY Argbash v2.4.1a one line above ### +### START OF CODE GENERATED BY Argbash v2.5.0 one line above ### # Argbash is a bash code generator used to get arguments parsing right. # Argbash is FREE SOFTWARE, see https://argbash.io for more info diff --git a/resources/examples/simple-wrapper.sh b/resources/examples/simple-wrapper.sh index 019d2c0..1743658 100755 --- a/resources/examples/simple-wrapper.sh +++ b/resources/examples/simple-wrapper.sh @@ -8,7 +8,7 @@ # ARGBASH_SET_INDENT([ ]) # ARGBASH_GO() # needed because of Argbash --> m4_ignore([ -### START OF CODE GENERATED BY Argbash v2.4.1a one line above ### +### START OF CODE GENERATED BY Argbash v2.5.0 one line above ### # Argbash is a bash code generator used to get arguments parsing right. # Argbash is FREE SOFTWARE, see https://argbash.io for more info diff --git a/resources/examples/simple.sh b/resources/examples/simple.sh index 35fd53b..46e30a2 100755 --- a/resources/examples/simple.sh +++ b/resources/examples/simple.sh @@ -4,7 +4,7 @@ # INCLUDE_PARSING_CODE([simple-parsing.sh]) # ARGBASH_GO() # needed because of Argbash --> m4_ignore([ -### START OF CODE GENERATED BY Argbash v2.4.1a one line above ### +### START OF CODE GENERATED BY Argbash v2.5.0 one line above ### # Argbash is a bash code generator used to get arguments parsing right. # Argbash is FREE SOFTWARE, see https://argbash.io for more info diff --git a/src/version b/src/version index af19722..437459c 100644 --- a/src/version +++ b/src/version @@ -1 +1 @@ -2.4.1a +2.5.0