-
-
Notifications
You must be signed in to change notification settings - Fork 23
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
Spaces in default value #46
Comments
This seems like a reasonable idea, but I would want to get it right, and there are a few rough cases:
Once we figure those out, and add tests and docs, then it sounds great! |
Indeed I see the Pandora's box of string quoting. The way I implemented in #47 cowardly avoid having to deal with it. It works as previously: This example just works and result in
This might not be intuitive or elegant but it is easy to use and always has a solution, even for strings that do start and end with quotes:
However, confusion may arise when users of the library might not expect quoting to be implemented and, expecting
One way around it would be to
|
As for string containing
|
Sorry for taking so long, but I think this has a path to life.
This is a reasonable idea, but I want docopt to be as opinionated and un-optioned as possible. Let's just go with the one least-bad behavior. I think it can be explained as
OK, I think that expected behavior you laid out seems reasonable. If you implement these test cases, I will accept #47: [
pytest.param(' leading space', ' leading space', id="leading_space_unquoted"),
pytest.param('" leading space"', ' leading space', id="leading_space_quoted"),
pytest.param(' "whitespace before"', "whitespace before", id="whitespace_before"),
pytest.param('"whitespace after" ', "whitespace after", id="whitespace_after"),
pytest.param('Dawyne "The Rock" Johnson', 'Dawyne "The Rock" Johnson', id="basic"),
pytest.param('"Dawyne "The Rock" Johnson"', 'Dawyne "The Rock" Johnson', id="nested"),
pytest.param('"Dawyne \'The Rock\' Johnson"', 'Dawyne "The Rock" Johnson', id="nested_mixed"),
pytest.param('"The Rock"', "The Rock", id="unneeded_quotes"),
pytest.param('"The Rock', '"The Rock', id="leading"),
pytest.param('The Rock"', 'The Rock"', id="trailing"),
pytest.param('"Dawyne "The Rock" Johnson', '"Dawyne "The Rock" Johnson', id="leading_with_inner"),
pytest.param('Dawyne "The Rock" Johnson"', 'Dawyne "The Rock" Johnson"', id="trailing_with_inner"),
pytest.param('"The Rock\'', '"The Rock\'', id="mixed"),
pytest.param('[]', "[]", id="unquoted_brackets"),
pytest.param('"[]"', "[]", id="quoted_brackets"),
pytest.param('"]"', "]", id="quoted_trailing_bracket"),
pytest.param('"]"', "]", id="quoted_trailing_bracket"),
]
...
doc = "default: " + inp Please note the If you can think of other ones, please add them! |
I would like to set a default value containing spaces like in
-
. It does work:But it is not so pleasing to the eye and prone to bad interpretation. I don't know what is the standard here, but I would imagine accepting a quoted default value, as in:
Could be one way to go. Or am I missing something ?
The text was updated successfully, but these errors were encountered: