Skip to content

Show how to read boolean flags from parsed arguments - #170

Open
Hugohong258 wants to merge 1 commit into
docopt:masterfrom
Hugohong258:docs/read-boolean-flags
Open

Hugohong258 wants to merge 1 commit into
docopt:masterfrom
Hugohong258:docs/read-boolean-flags

Conversation

@Hugohong258

Copy link
Copy Markdown

The Naval Fate example prints the parsed values but does not show how to branch on a flag. A direct if (args.at("--moored")) enters the branch even when the flag is omitted: the value contains the boolean false. Show how to read that boolean using asBool().

I compiled the README example with the new snippet against docopt.cpp using GCC 15.2 in C++11 mode. Running it with and without the flag entered the branch only when the flag was supplied. The example with a direct condition reproduced the behavior described in #156.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant