diff --git a/lbry/service/parser.py b/lbry/service/parser.py index 70e1e6071..c37cf5db6 100644 --- a/lbry/service/parser.py +++ b/lbry/service/parser.py @@ -159,7 +159,9 @@ def parse_method(method, expanders: dict) -> dict: raise Exception(f"Expander '{expander_name}' not found, used by {d['name']}.") for expanded in expanders[expander_name]: if expanded['name'] in known_names: - raise Exception(f"Expander '{expander_name}' argument repeated: {expanded['name']}.") + raise Exception( + f"Expander '{expander_name}' argument repeated '{expanded['name']}' used by {d['name']}." + ) d['arguments'].append(expanded) d['kwargs'].append(expanded) known_names.add(expanded['name']) @@ -213,11 +215,12 @@ def generate_options(method, indent) -> List[str]: if 'default' in arg: if arg['type'] != 'bool': text += f" [default: {arg['default']}]" - wrapped = textwrap.wrap(text, LINE_WIDTH-len(left)) + wrapped = textwrap.wrap(text, LINE_WIDTH-len(left), break_long_words=False) lines = [f"{left}{wrapped.pop(0)}"] # dont break on -- or docopt will parse as a new option for line in wrapped: if line.strip().startswith('--'): + print(f"Full text before continuation error: \"{text}\"") raise Exception(f"Continuation line starts with -- on {method['cli']}: \"{line.strip()}\"") lines.append(f"{' ' * len(left)} {line}") options.extend(lines) diff --git a/tests/unit/service/test_parser.py b/tests/unit/service/test_parser.py index 90c873dac..38a35063a 100644 --- a/tests/unit/service/test_parser.py +++ b/tests/unit/service/test_parser.py @@ -97,7 +97,10 @@ class TestParser(TestCase): def test_parse_does_not_allow_duplicate_arguments(self): with self.assertRaises(Exception) as exc: parse_method(BadAPI.thing_search, get_expanders()) - self.assertEqual(exc.exception.args[0], "Expander 'another_test' argument repeated: somevalue.") + self.assertEqual( + exc.exception.args[0], + "Expander 'another_test' argument repeated 'somevalue' used by thing_search." + ) def test_parse_does_not_allow_line_break_with_two_dashes(self): # breaking with two dashes breaks docopt parsing