Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes default option value (closes issue #26) #27

Merged
merged 1 commit into from
Mar 10, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docopt.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,8 @@ int elems_to_args(Elements *elements, DocoptArgs *args, bool help,
} else if (!strcmp(option->olong, "--version")) {
args->version = option->value;
} else if (!strcmp(option->olong, "--speed")) {
args->speed = option->argument;
if (option->argument)
args->speed = option->argument;
}
}
/* commands */
Expand Down Expand Up @@ -363,3 +364,4 @@ DocoptArgs docopt(int argc, char *argv[], bool help, const char *version) {
exit(EXIT_SUCCESS);
return args;
}

3 changes: 2 additions & 1 deletion docopt_c.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ def c_if_flag(o):

def c_if_option(o):
t = """ else if (!strcmp(option->o%s, %s)) {
args->%s = option->argument;
if (option->argument)
args->%s = option->argument;
}"""
return t % (('long' if o.long else 'short'),
to_c(o.long or o.short),
Expand Down