summaryrefslogtreecommitdiff
path: root/test-parse-options.c
diff options
context:
space:
mode:
authorCharles Bailey <cbailey32@bloomberg.net>2015-06-21 19:25:44 +0100
committerJunio C Hamano <gitster@pobox.com>2015-06-22 15:07:21 -0700
commit2a514ed8058e35841d3d7b05a898991b83e5eaf0 (patch)
treeeb121b83543970a0f21988d5f301743692e788b3 /test-parse-options.c
parent81a48cc08033a453bcb884ec0838a8f064a6611e (diff)
downloadgit-2a514ed8058e35841d3d7b05a898991b83e5eaf0.tar.gz
parse-options: move unsigned long option parsing out of pack-objects.ccb/parse-magnitude
The unsigned long option parsing (including 'k'/'m'/'g' suffix parsing) is more widely applicable. Add support for OPT_MAGNITUDE to parse-options.h and change pack-objects.c use this support. The error behavior on parse errors follows that of OPT_INTEGER. The name of the option that failed to parse is reported with a brief message describing the expect format for the option argument and then the full usage message for the command invoked. This differs from the previous behavior for OPT_ULONG used in pack-objects for --max-pack-size and --window-memory which used to display the value supplied in the error message and did not display the full usage message. Signed-off-by: Charles Bailey <cbailey32@bloomberg.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'test-parse-options.c')
-rw-r--r--test-parse-options.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/test-parse-options.c b/test-parse-options.c
index 7c492cf724..2c8c8f18ed 100644
--- a/test-parse-options.c
+++ b/test-parse-options.c
@@ -4,6 +4,7 @@
static int boolean = 0;
static int integer = 0;
+static unsigned long magnitude = 0;
static unsigned long timestamp;
static int abbrev = 7;
static int verbose = 0, dry_run = 0, quiet = 0;
@@ -48,6 +49,7 @@ int main(int argc, char **argv)
OPT_GROUP(""),
OPT_INTEGER('i', "integer", &integer, "get a integer"),
OPT_INTEGER('j', NULL, &integer, "get a integer, too"),
+ OPT_MAGNITUDE('m', "magnitude", &magnitude, "get a magnitude"),
OPT_SET_INT(0, "set23", &integer, "set integer to 23", 23),
OPT_DATE('t', NULL, &timestamp, "get timestamp of <time>"),
OPT_CALLBACK('L', "length", &integer, "str",
@@ -83,6 +85,7 @@ int main(int argc, char **argv)
printf("boolean: %d\n", boolean);
printf("integer: %d\n", integer);
+ printf("magnitude: %lu\n", magnitude);
printf("timestamp: %lu\n", timestamp);
printf("string: %s\n", string ? string : "(not set)");
printf("abbrev: %d\n", abbrev);