Reinstate ordering of arguments in bin/storm.py - #8971
Conversation
bin/storm.py
|
Hi @sercuzz8, Thanks for tackling this, the diagnosis is right, and reconstructing the order from
if len(merged) != len(known_args) + len(unknown_args):
raise ValueError("could not reconstruct argument order from sys.argv")or fall back to the old concatenation, if you'd rather not add a new failure path to a released CLI.
from collections import Counter
remaining = Counter(known_args) + Counter(unknown_args)
merged = []
for token in sys_args:
if remaining[token]:
remaining[token] -= 1
merged.append(token)Nits: the |
Summary
argparse's
parse_known_args()splitsmain_args(nargs='*') from unrecognized flags(
unknown_args), losing their relative order when they are interleaved on the command line.This breaks down the flow of
mvn clean install, thus the order must be reinstated.Following this discussion