aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2013-08-23 21:35:27 +0200
committerMattias Andrée <maandree@operamail.com>2013-08-23 21:35:27 +0200
commit4cafa7d686454309bdc7a63591133a88817c3719 (patch)
treeb2d1db39a1e9e8a0fa93f61e0921ffe5402cf9e8 /src
parentissue 2, python version (diff)
downloadargparser-4cafa7d686454309bdc7a63591133a88817c3719.tar.gz
argparser-4cafa7d686454309bdc7a63591133a88817c3719.tar.bz2
argparser-4cafa7d686454309bdc7a63591133a88817c3719.tar.xz
m fix bash and java version
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src')
-rw-r--r--src/argparser.bash13
-rw-r--r--src/argparser/ArgParser.java8
2 files changed, 13 insertions, 8 deletions
diff --git a/src/argparser.bash b/src/argparser.bash
index c828360..72567a6 100644
--- a/src/argparser.bash
+++ b/src/argparser.bash
@@ -676,17 +676,20 @@ function args_parse
if [ $argnull = 0 ]; then
arg="${argqueue[$i]}"
fi
+ std="$(head -n 1 < "${args_optmap}/${opt}")"
+ trigger="$(tail -n 1 < "${args_optmap}/${opt}")"
+ if (( ${#argqueue[@]} <= $i )); then
+ "$trigger" "${opt}" "${std}"
+ fi
(( i++ ))
- opt="$(head -n 1 < "${args_optmap}/${opt}")"
+ opt="${std}"
if [ ! -e "${args_opts}/${opt}" ]; then
mkdir -p "${args_opts}/${opt}"
echo -n > "${args_opts}/${opt}/data"
echo -n > "${args_opts}/${opt}/null"
fi
- if (( ${#argqueue[@]} >= $i )); then
- echo "$arg" >> "${args_opts}/${opt}/data"
- echo "$argnull" >> "${args_opts}/${opt}/null"
- fi
+ echo "$arg" >> "${args_opts}/${opt}/data"
+ echo "$argnull" >> "${args_opts}/${opt}/null"
done
i=0
diff --git a/src/argparser/ArgParser.java b/src/argparser/ArgParser.java
index 931e79f..fd97f81 100644
--- a/src/argparser/ArgParser.java
+++ b/src/argparser/ArgParser.java
@@ -1163,13 +1163,15 @@ public class ArgParser
int i = 0, n = optqueue.size();
while (i < n)
{
- final String opt = this.optmap.get(optqueue.get(i)).standard;
+ final Option option = this.optmap.get(optqueue.get(i));
+ final String opt = option.standard;
final String arg = argqueue.size() > i ? argqueue.get(i) : null;
+ if (len(argqueue) <= i)
+ option.trigger(optqueue.get(i), null);
i++;
if (this.opts.get(opt) == null)
this.opts.put(opt, new String[] {});
- if (argqueue.size() >= i)
- this.opts.put(opt, append(this.opts.get(opt), arg));
+ this.opts.put(opt, append(this.opts.get(opt), arg));
}
for (final Option opt : this.options)