]> git.corax.cc Git - toolbox/commitdiff
include/{opt,inst}: Add regex parameter to opt_add_arg() calls
authorMatthias Kruk <m@m10k.eu>
Mon, 21 Jun 2021 23:49:42 +0000 (08:49 +0900)
committerMatthias Kruk <m@m10k.eu>
Mon, 21 Jun 2021 23:49:42 +0000 (08:49 +0900)
The opt and inst modules use opt_add_arg() to register command line
arguments with a callback, however they omit the newly-added regex
argument, causing the callbacks not to be called.
This commit fixes the order of arguments passed to opt_add_arg() so
that the command line arguments are registered correctly.

include/inst.sh
include/opt.sh

index 678a2ae8774a5a2eff063d5f3954b77d9dc79a57..9d627d31dc5cc27ad8c4c2400976a5fee8a7c576 100644 (file)
@@ -37,8 +37,8 @@ __init() {
                return 1
        fi
 
-       opt_add_arg "l" "list" ""  0  "List running instances"  _inst_handle_opt
-       opt_add_arg "s" "stop" "v" "" "Stop a running instance" _inst_handle_opt
+       opt_add_arg "l" "list" ""  0  "List running instances"  ''         _inst_handle_opt
+       opt_add_arg "s" "stop" "v" "" "Stop a running instance" '^[0-9]+$' _inst_handle_opt
 
        return 0
 }
index a4ac69e7815505bb8f823c7a24cb3ec2839df043..3a32b5a5607d15a4425debc3ce163cfcbca0cb5d 100644 (file)
@@ -38,13 +38,16 @@ __init() {
 
        opt_add_arg "h" "help" "" 0 \
                    "Print this text" \
+                   '' \
                    opt_print_help
 
        opt_add_arg "v" "verbose" "" 0 \
                    "Be more verbose" \
+                   '' \
                    log_increase_verbosity
        opt_add_arg "q" "quiet" "" 0 \
                    "Be less verbose" \
+                   '' \
                    log_decrease_verbosity
 
        return 0