aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2013-08-26 13:21:30 +0200
committerMattias Andrée <maandree@operamail.com>2013-08-26 13:21:30 +0200
commite73228aaafce7901a6a39cf4ce6dbfdbf8f0a6b2 (patch)
treee953538a8ff426089f2955918824509d558fe84f /src
parentissue 2, info manual (diff)
downloadargparser-e73228aaafce7901a6a39cf4ce6dbfdbf8f0a6b2.tar.gz
argparser-e73228aaafce7901a6a39cf4ce6dbfdbf8f0a6b2.tar.bz2
argparser-e73228aaafce7901a6a39cf4ce6dbfdbf8f0a6b2.tar.xz
update test
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r--src/Test.java5
-rwxr-xr-xsrc/test.bash13
-rw-r--r--src/test.c8
3 files changed, 24 insertions, 2 deletions
diff --git a/src/Test.java b/src/Test.java
index 27473ab..a06a0fe 100644
--- a/src/Test.java
+++ b/src/Test.java
@@ -46,6 +46,7 @@ public class Test
parser.add(new ArgParser.Argumentless(0, "++hidden"));
parser.add(new ArgParser.Argumented("LINE", 0, "-l", "--line"), "Prints the choosen line");
+ parser.add(new ArgParser.Optargumented("LINE", 0, "-L", "--Line"), "Prints the choosen line");
parser.add(new ArgParser.Variadic("LINE", 0, "--l", "--lines"), "Prints the choosen lines");
parser.parse(args);
@@ -63,6 +64,10 @@ public class Test
{ for (String line : parser.opts.get("--line"))
System.out.println(line);
}
+ if (parser.opts.get("-L") != null)
+ { for (String line : parser.opts.get("--Line"))
+ System.out.println(line);
+ }
if (parser.opts.get("--lines") != null)
{ for (String line : parser.opts.get("--l"))
System.out.println(line);
diff --git a/src/test.bash b/src/test.bash
index 136439c..71e6137 100755
--- a/src/test.bash
+++ b/src/test.bash
@@ -49,8 +49,9 @@ args_add_argumentless '' 0 'Prints this help message\n(and exits)' -h -? --he
args_add_argumentless '' 0 'Prints the text: hello world' --hello
args_add_argumentless '' 0 '' ++hidden
-args_add_argumented '' 0 LINE 'Prints the choosen line' -l --line
-args_add_variadic '' 0 LINE 'Prints the choosen lines' --l --lines
+args_add_argumented '' 0 LINE 'Prints the choosen line' -l --line
+args_add_optargumented '' '' 0 LINE 'Prints the choosen line' -l --Line
+args_add_variadic '' 0 LINE 'Prints the choosen lines' --l --lines
args_parse "$@"
args_support_alternatives
@@ -74,6 +75,14 @@ elif [ $args_unrecognised_count = 0 ] && [ ! $args_argcount = 0 ] && [ ${#args_f
(( i++ ))
done
fi
+ if args_option has -L; then
+ i=0
+ n=$(args_option count --Line)
+ while (( $i < $n )); do
+ args_option get --Line $i
+ (( i++ ))
+ done
+ fi
if args_option has --lines; then
i=0
n=$(args_option count --l)
diff --git a/src/test.c b/src/test.c
index fbd8ada..4e52f1e 100644
--- a/src/test.c
+++ b/src/test.c
@@ -48,6 +48,7 @@ int main(int argc, char** argv)
args_add_option(args_new_argumentless(NULL, 0, "++hidden", NULL), 0);
args_add_option(args_new_argumented(NULL, "LINE", 0, "-l", "--line", NULL), "Prints the choosen line");
+ args_add_option(args_new_optargumented(NULL, NULL, "LINE", 0, "-L", "--Line", NULL), "Prints the choosen line");
args_add_option(args_new_variadic(NULL, "LINE", 0, "--l", "--lines", NULL), "Prints the choosen lines");
args_parse(argc, argv);
@@ -70,6 +71,13 @@ int main(int argc, char** argv)
for (n = args_opts_get_count("--line"); i < n; i++)
printf("%s\n", *(arr + i));
}
+ if (args_opts_used("-L"))
+ {
+ i = 0;
+ arr = args_opts_get("--Line");
+ for (n = args_opts_get_count("--Line"); i < n; i++)
+ printf("%s\n", *(arr + i));
+ }
if (args_opts_used("--lines"))
{
i = 0;