Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Commit

Permalink
_index_argv: Handle "-jX" style short options with argument
Browse files Browse the repository at this point in the history
Before, _index_arg (and _in_argv) would not function correctly in this
case.

This change makes the recently added tests pass and closes clueboard#69.
  • Loading branch information
jepler committed Jul 11, 2022
1 parent b12fe42 commit a0fc9c5
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions milc/_in_argv.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@ def _index_argv(argument):
Since long options can be passed as either '--option value' or '--option=value' we need to check for both forms.
"""
for i, arg in enumerate(sys.argv):
if arg.split('=')[0] == argument:
return i
if argument.startswith('--'):
for i, arg in enumerate(sys.argv):
if arg.split('=')[0] == argument:
return i
else:
for i, arg in enumerate(sys.argv):
if arg.startswith(argument):
return i

return None

0 comments on commit a0fc9c5

Please sign in to comment.