mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-06 04:17:55 +00:00
Convert parse_option to sh, use Perl instead of awk, implement --help.
This commit is contained in:
@@ -66,12 +66,21 @@ is "$OPT_VERSION" "yes" "Short form"
|
||||
|
||||
# Have to call this in a subshell because the error will cause an exit.
|
||||
parse_options "$T_LIB_DIR/samples/bash/po001.sh" --foo >$TMPFILE 2>&1
|
||||
is "`cat $TMPFILE`" "" "No warnings or errors yet"
|
||||
cmd_ok "grep -q 'Unknown option: --foo' $TMPFILE" "Error on unknown option"
|
||||
|
||||
usage_or_errors "$T_LIB_DIR/samples/bash/po001.sh" >$TMPFILE 2>&1
|
||||
local err=$?
|
||||
is "$err" "1" "Non-zero exit on unknown option"
|
||||
cmd_ok "grep -q 'Unknown option: --foo' $TMPFILE" "Error on unknown option"
|
||||
|
||||
# ###########################################################################
|
||||
# --help
|
||||
# ###########################################################################
|
||||
parse_options "$T_LIB_DIR/samples/bash/po001.sh" --help
|
||||
usage_or_errors "$T_LIB_DIR/samples/bash/po001.sh" >$TMPFILE 2>&1
|
||||
no_diff \
|
||||
"$TMPFILE" \
|
||||
"$T_LIB_DIR/samples/bash/help001.txt" \
|
||||
"--help"
|
||||
|
||||
# ############################################################################
|
||||
# Done
|
||||
|
30
t/lib/samples/bash/help001.txt
Normal file
30
t/lib/samples/bash/help001.txt
Normal file
@@ -0,0 +1,30 @@
|
||||
Usage: pt-stalk [OPTIONS] [-- MYSQL_OPTIONS]
|
||||
|
||||
For more information, 'man pt-stalk' or 'perldoc /Users/daniel/p/bash-tool-libs/t/lib/samples/bash/po001.sh'.
|
||||
|
||||
Command line options:
|
||||
|
||||
--help
|
||||
Print help and exit.
|
||||
|
||||
--int-opt
|
||||
Int option without a default.
|
||||
|
||||
--int-opt2
|
||||
Int option with a default.
|
||||
|
||||
--noption
|
||||
Negatable option.
|
||||
|
||||
--string-opt
|
||||
String option without a default.
|
||||
|
||||
--string-opt2
|
||||
String option with a default.
|
||||
|
||||
--typeless-option
|
||||
Just an option.
|
||||
|
||||
--version
|
||||
Print tool's version and exit.
|
||||
|
@@ -110,11 +110,13 @@ Just an option.
|
||||
|
||||
default: yes; negatable: yes
|
||||
|
||||
Negatable option.
|
||||
|
||||
=item --int-opt
|
||||
|
||||
type: int
|
||||
|
||||
Int option without a default
|
||||
Int option without a default.
|
||||
|
||||
=item --int-opt2
|
||||
|
||||
@@ -128,6 +130,10 @@ short form: -v
|
||||
|
||||
Print tool's version and exit.
|
||||
|
||||
=item --help
|
||||
|
||||
Print help and exit.
|
||||
|
||||
=back
|
||||
|
||||
=head1 ENVIRONMENT
|
||||
|
Reference in New Issue
Block a user