Skip to content

Commit

Permalink
Merge branch 'fix_osc_api_without_arguments' of https://github.com/le…
Browse files Browse the repository at this point in the history
…thliel/osc

Fix handling of incorrect CLI arguments (python3).
  • Loading branch information
marcus-h committed May 18, 2020
2 parents 2b26419 + 69b1233 commit 9b2cbfe
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions osc/cmdln.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ def introspect_handler_3(handler):
_INCORRECT_NUM_ARGS_RE = re.compile(
r"(takes [\w ]+ )(\d+)( arguments? \()(\d+)( given\))")

_INCORRECT_NUM_ARGS_RE_PY3 = re.compile(
r"(missing\s+\d+.*)")

# Static bits of man page
MAN_HEADER = r""".TH %(ucname)s "1" "%(date)s" "%(name)s %(version)s" "User Commands"
.SH NAME
Expand Down Expand Up @@ -1246,6 +1249,7 @@ def do_bar2(self, subcmd, opts, bar_one, bar_two):
raise
msg = ex.args[0]
match = _INCORRECT_NUM_ARGS_RE.search(msg)
match_py3 = _INCORRECT_NUM_ARGS_RE_PY3.search(msg)
if match:
msg = list(match.groups())
msg[1] = int(msg[1]) - 3
Expand All @@ -1254,6 +1258,8 @@ def do_bar2(self, subcmd, opts, bar_one, bar_two):
msg[3] = int(msg[3]) - 3
msg = ''.join(map(str, msg))
raise CmdlnUserError(msg)
elif match_py3:
raise CmdlnUserError(match_py3.group(1))
else:
raise
else:
Expand Down

0 comments on commit 9b2cbfe

Please sign in to comment.