diff --git a/docopt_private.h b/docopt_private.h index 77bf2bd..abe67de 100644 --- a/docopt_private.h +++ b/docopt_private.h @@ -530,7 +530,7 @@ namespace docopt { options_end = option_description.begin() + static_cast(double_space); } - static const std::regex pattern {"(-{1,2})?(.*?)([,= ]|$)"}; + static const std::regex pattern {"(-{1,2})?(.*?)([,= \n]|$)"}; for(std::sregex_iterator i {option_description.begin(), options_end, pattern, std::regex_constants::match_not_null}, e{}; i != e; diff --git a/testcases.docopt b/testcases.docopt index efe9a07..c74613d 100644 --- a/testcases.docopt +++ b/testcases.docopt @@ -955,3 +955,23 @@ other options: """ $ prog --baz --egg {"--foo": false, "--baz": true, "--bar": false, "--egg": true, "--spam": false} + + +# An option description can be located after a new line. +r"""usage: prog [options] + +options: + --foo, -f + Description on a new line. + --bar, -b + Description on a new line. +""" + +$ prog --foo +{"--foo": true, "--bar": false} +$ prog --f +{"--foo": true, "--bar": false} +$ prog --bar +{"--foo": false, "--bar": true} +$ prog -b +{"--foo": false, "--bar": true}