-b, --boolean get a boolean
-4, --or4 bitwise-or boolean with ...0100
+ --neg-or4 same as --no-or4
-i, --integer <n> get a integer
-j <n> get a integer, too
Magic arguments
--quux means --quux
+ -NUM set integer to NUM
+ + same as -b
Standard options
--abbrev[=<n>] use <n> digits to display SHA-1s
cat > expect << EOF
boolean: 2
integer: 1729
+timestamp: 0
string: 123
abbrev: 7
verbose: 2
cat > expect << EOF
boolean: 2
integer: 1729
+timestamp: 0
string: 321
abbrev: 10
verbose: 2
test_cmp expect output
'
+test_expect_success 'missing required value' '
+ test-parse-options -s;
+ test $? = 129 &&
+ test-parse-options --string;
+ test $? = 129
+'
+
cat > expect << EOF
boolean: 1
integer: 13
+timestamp: 0
string: 123
abbrev: 7
verbose: 0
cat > expect << EOF
boolean: 0
integer: 2
+timestamp: 0
string: (not set)
abbrev: 7
verbose: 0
cat > expect << EOF
boolean: 0
integer: 0
+timestamp: 0
string: 123
abbrev: 7
verbose: 0
cat > expect <<EOF
boolean: 0
integer: 0
+timestamp: 0
string: (not set)
abbrev: 7
verbose: 0
cat > expect <<EOF
boolean: 0
-integer: 1
+integer: 0
+timestamp: 1
string: default
abbrev: 7
verbose: 0
Callback: "four", 0
boolean: 5
integer: 4
+timestamp: 0
string: (not set)
abbrev: 7
verbose: 0
cat > expect <<EOF
boolean: 1
integer: 23
+timestamp: 0
string: (not set)
abbrev: 7
verbose: 0
test_cmp expect output
'
-# --or4
-# --no-or4
+test_expect_success 'OPT_NEGBIT() and OPT_SET_INT() work' '
+ test-parse-options --set23 -bbbbb --neg-or4 > output 2> output.err &&
+ test ! -s output.err &&
+ test_cmp expect output
+'
+
+cat > expect <<EOF
+boolean: 6
+integer: 0
+timestamp: 0
+string: (not set)
+abbrev: 7
+verbose: 0
+quiet: no
+dry run: no
+EOF
+
+test_expect_success 'OPT_BIT() works' '
+ test-parse-options -bb --or4 > output 2> output.err &&
+ test ! -s output.err &&
+ test_cmp expect output
+'
+
+test_expect_success 'OPT_NEGBIT() works' '
+ test-parse-options -bb --no-neg-or4 > output 2> output.err &&
+ test ! -s output.err &&
+ test_cmp expect output
+'
+
+test_expect_success 'OPT_BOOLEAN() with PARSE_OPT_NODASH works' '
+ test-parse-options + + + + + + > output 2> output.err &&
+ test ! -s output.err &&
+ test_cmp expect output
+'
+
+cat > expect <<EOF
+boolean: 0
+integer: 12345
+timestamp: 0
+string: (not set)
+abbrev: 7
+verbose: 0
+quiet: no
+dry run: no
+EOF
+
+test_expect_success 'OPT_NUMBER_CALLBACK() works' '
+ test-parse-options -12345 > output 2> output.err &&
+ test ! -s output.err &&
+ test_cmp expect output
+'
test_done