You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by nw...@apache.org on 2015/02/01 23:05:38 UTC
[2/5] lucy-charmonizer git commit: Support both '--opt=val' and
'--opt val' styles.
Support both '--opt=val' and '--opt val' styles.
Project: http://git-wip-us.apache.org/repos/asf/lucy-charmonizer/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-charmonizer/commit/d379ebe4
Tree: http://git-wip-us.apache.org/repos/asf/lucy-charmonizer/tree/d379ebe4
Diff: http://git-wip-us.apache.org/repos/asf/lucy-charmonizer/diff/d379ebe4
Branch: refs/heads/master
Commit: d379ebe4d91741e0aa5d7e923223d4f17b36f43d
Parents: 66edcd9
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Sun Feb 1 22:45:11 2015 +0100
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sun Feb 1 22:45:11 2015 +0100
----------------------------------------------------------------------
src/Charmonizer/Core/CLI.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy-charmonizer/blob/d379ebe4/src/Charmonizer/Core/CLI.c
----------------------------------------------------------------------
diff --git a/src/Charmonizer/Core/CLI.c b/src/Charmonizer/Core/CLI.c
index d675a20..b913c66 100644
--- a/src/Charmonizer/Core/CLI.c
+++ b/src/Charmonizer/Core/CLI.c
@@ -345,6 +345,21 @@ chaz_CLI_parse(chaz_CLI *self, int argc, const char *argv[]) {
memcpy(name, arg + 2, name_len);
name[name_len] = '\0';
+ if (value == NULL && i + 1 < argc) {
+ /* Support both '--opt=val' and '--opt val' styles. */
+ chaz_CLIOption *opt = S_find_opt(self, name);
+ if (opt == NULL) {
+ S_chaz_CLI_error(self, "Attempt to set unknown option: '%s'",
+ name);
+ free(name);
+ return 0;
+ }
+ if (opt->flags != CHAZ_CLI_NO_ARG) {
+ i++;
+ value = argv[i];
+ }
+ }
+
/* Attempt to set the option. */
if (!chaz_CLI_set(self, name, value)) {
free(name);