-
Notifications
You must be signed in to change notification settings - Fork 561
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
Indentation-sensitive usage? #102
Comments
If POSIX defines usage as indentation-sensitive then we should do that too, provided it doesn't complicate the implementation overmuch. |
Then, maybe, require to have |
This is now in master, however I'm still not 100% sure: it seems like a good idea, but it will brake a lot of code. As per new implementation there are 2 kinds of sections: usage-sections, and options-sections. They both are parsed in the same way:
This makes the following things valid (from new testcases): r"""Usage: prog [options]
global options: --foo
local options: --baz
--bar
other OPTIONS:
--egg
--spam
-not-an-option-
""" |
This has broken printing usage on exit since the following line was removed: DocoptExit.usage = printable_usage(doc) |
Oh, thanks for noticing. Too bad we don't have any tests that capture stdin/stdout right now. |
I prefer having indentation sensitive, as it will forces a certain standard across docopt strings. |
In current master the regex for "section" is: re.compile('^([^\n]*' + section_name + '[^\n]*\n?(?:[ \t].*?(?:\n|$))*)', re.IGNORECASE | re.MULTILINE) Which is not final, and maybe someone can comment on it or propose a different one. This one will match as long as there is some indentation (at least one space or one tab): |
I'm actually very unhappy with this regexp. It makes even harder to describe docopt formally (using some grammar). Also harder to explain. I'm still sure that "sections" is a good feature, I'm just not sure how to implement them. I need to think more about it. This will delay 0.7.0 release. Sorry @shabbyrobe for breaking your plans with releasing PHP 0.7.0 again :-( |
Hehehe, it's all good, there's a develop branch in there, and the "everything in one file" is making it super easy for me to drop it in to projects as needed. I reckon it's better to take your time and get it right. I'm in no hurry 😃 |
I have seen at least 3 times people (including me :-) made the mistake of not putting newline after usage:
(from http://futuregrid.github.com/cmd3/manual.html#argument-parsing)
Maybe we should do something about it? Either:
Opinions? @docopt
The text was updated successfully, but these errors were encountered: