Add support for argument defaults #37

wants to merge 1 commit into


None yet
4 participants

Met48 commented Jul 6, 2012

Argument descriptions will be recognized as any line that starts with an argument.
It will be ignored if there is not a [default: ] section in the description. Multi-line descriptions are supported.

This commit fixes issue #36. It also disables option parsing within any usage: section.

@Met48 Met48 Add support for argument defaults, fix issue #36.
Argument defaults will match on any non-usage line
that starts with  <.*>  or  [A-Z]+

Supports multi-line descriptions.

keleshev commented Jul 13, 2012

Sorry, I was busy the whole week. I will review your code now.

I wonder if it is possible to implement the same in less code... I'm very afraid of docopt growing.


Met48 commented Jul 13, 2012

The code volume could be decreased, although there's a few reasons for the additional code:

  1. It has to ignore anything in a usage: section. This took ~15 lines.
  2. It now supports tab characters for indentation and description separation. I omitted this from the commit message by mistake, but it is there and underwent local testing (no test cases added). This adds another ~12 lines since partition could no longer be used
  3. It moves the common parse code outside of the parse method. This actually saves a few lines in both parse methods but increases the apparent diff size

EDIT: Edited comment a bit for clarity.

Unknown referenced this pull request Aug 10, 2012


Add support for enumerations #45


keleshev commented Aug 29, 2012

Support for this is upcoming in 0.6.0, and is now in a branch:

Sorry @Met48 for not including your code—I want docopt to be as small as possible (in terms of LOC), so I came up with my own solution, which is a bit shorter.

Also branch supports only <angular-bracket> style for arguments—I'm thinking of keeping it the only style (maybe). If not, I will add support for default arguments for UPPER-CASE style as well.

jric commented Aug 15, 2013

+1 -- Iet me know if I can help

csaftoiu commented Aug 6, 2016

Support for this is added now - worth closing the PR?

Met48 closed this Aug 6, 2016

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