Show More
@@ -61,6 +61,8 b' def swallow_argv(argv, aliases=None, flags=None):' | |||||
61 | swallow_next = False |
|
61 | swallow_next = False | |
62 | was_flag = False |
|
62 | was_flag = False | |
63 | for a in argv: |
|
63 | for a in argv: | |
|
64 | if a == '--': | |||
|
65 | break | |||
64 | if swallow_next: |
|
66 | if swallow_next: | |
65 | swallow_next = False |
|
67 | swallow_next = False | |
66 | # last arg was an alias, remove the next one |
|
68 | # last arg was an alias, remove the next one | |
@@ -71,16 +73,16 b' def swallow_argv(argv, aliases=None, flags=None):' | |||||
71 | continue |
|
73 | continue | |
72 | if a.startswith('-'): |
|
74 | if a.startswith('-'): | |
73 | split = a.lstrip('-').split('=') |
|
75 | split = a.lstrip('-').split('=') | |
74 |
|
|
76 | name = split[0] | |
75 | if alias in aliases: |
|
77 | if any(alias.startswith(name) for alias in aliases): | |
76 | stripped.remove(a) |
|
78 | stripped.remove(a) | |
77 | if len(split) == 1: |
|
79 | if len(split) == 1: | |
78 | # alias passed with arg via space |
|
80 | # alias passed with arg via space | |
79 | swallow_next = True |
|
81 | swallow_next = True | |
80 | # could have been a flag that matches an alias, e.g. `existing` |
|
82 | # could have been a flag that matches an alias, e.g. `existing` | |
81 | # in which case, we might not swallow the next arg |
|
83 | # in which case, we might not swallow the next arg | |
82 |
was_flag = |
|
84 | was_flag = name in flags | |
83 | elif alias in flags and len(split) == 1: |
|
85 | elif len(split) == 1 and any(flag.startswith(name) for flag in flags): | |
84 | # strip flag, but don't swallow next, as flags don't take args |
|
86 | # strip flag, but don't swallow next, as flags don't take args | |
85 | stripped.remove(a) |
|
87 | stripped.remove(a) | |
86 |
|
88 |
General Comments 0
You need to be logged in to leave comments.
Login now