@@ -326,7 +326,7 @@ argsparse_minimum_parameters() {
326
326
# # @details The default maximum parameters requirement for command
327
327
# # line. "Should be enough for everyone".
328
328
# # @ingroup ArgsparseParameter
329
- declare -i __argsparse_maximum_parameters=100000
329
+ declare -i __argsparse_maximum_parameters=1000000
330
330
331
331
# # @fn argsparse_maximum_parameters()
332
332
# # @brief Set the maximum number of non-option parameters expected on
@@ -615,28 +615,54 @@ argsparse_usage_short() {
615
615
616
616
declare -a __argsparse_parameters_description
617
617
618
- __argsparse_describe_parameters () {
618
+ # # @fn argsparse_describe_parameters()
619
+ # # @brief Describe non-option positionnal parameters.
620
+ # # @details
621
+ # # This function has currently 2 purposes:
622
+ # # @li enhance the "short" usage program description (see
623
+ # # argsparse_usage_short())
624
+ # # @li compute the minimum and maximum numbers of non-option
625
+ # # positionnal parameters and will overwrite previous settings using
626
+ # # argsparse_minimum_parameters() and argsparse_maximum_parameters().
627
+ # #
628
+ # # @param param... a list of label describing positionnal
629
+ # # parameters. These labels can have special forms such as:
630
+ # # @li "label?" a single optional non-repeatable parameter
631
+ # # @li "label+" a non-empty list of parameters
632
+ # # @li "label*" a potentially-empty list of parameters
633
+ # # @li "label" a single non-optional non-repeatable parameter
634
+ # # @retval 0
635
+ argsparse_describe_parameters () {
619
636
[[ $# -eq 0 ]] && return
620
637
local param last name
638
+ local -i min=0 max=0
621
639
__argsparse_parameter_description=( " [--]" )
622
640
for param in " $@ "
623
641
do
624
642
name=${param% ?}
625
643
last=${param# $name }
626
644
case " $last " in
627
645
' ?' )
646
+ : maximum param $(( ++ max))
628
647
__argsparse_parameters_description+=( " [ $name ]" )
629
648
;;
630
649
' *' )
650
+ max=1000000
631
651
__argsparse_parameters_description+=( " [ $name ... ]" )
632
652
;;
633
653
+)
654
+ max=1000000
655
+ : minimum param $(( ++ min))
634
656
__argsparse_parameters_description+=( " $name [ $name ... ]" )
635
657
;;
636
658
* )
659
+ : maximum param $(( ++ max))
660
+ : minimum param $(( ++ min))
637
661
__argsparse_parameters_description+=( " $param " )
638
662
esac
639
663
done
664
+ argsparse_minimum_parameters " $min "
665
+ argsparse_maximum_parameters " $max "
640
666
}
641
667
642
668
# # @fn argsparse_usage_long()
0 commit comments