Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept subcomands as last element in x.py argv #38534

Closed
wants to merge 2 commits into from

Conversation

estebank
Copy link
Contributor

Fix #38373.

@rust-highfive
Copy link
Collaborator

r? @brson

(rust_highfive has picked a reviewer for you, use r? to override)

@nagisa
Copy link
Member

nagisa commented Dec 22, 2016

I think we should still just use a proper argument parser. The thing is that while

python x.py --stage 1 test

is a valid command

python x.py --stage 1 test src/libstd

is also valid, and will not work with this patch.

@estebank
Copy link
Contributor Author

You're right, but then there would be parsing code in two different places, in two different languages. This seemed like a quick workaround for the time being. I was already uneasy about having the list of subcommands there.

I could also look for the presence of a subcommand and move everything that comes after to the front of the argv list. This is still not ideal and could break, but seems to me like a close enough heuristic that would not be broken now and that would relief this annoyance in the meantime without having to duplicate argv parsing code in Python and Rust.

@nagisa
Copy link
Member

nagisa commented Dec 23, 2016

Is it even necessary for python part to parse any arguments? Why can’t it just pass them through (and rustbuild (the rust part) properly handle everything)?

@alexcrichton
Copy link
Member

Thanks for the PR! I think that the bug though lies not in the python script but rather here in the Rust code. Python's correctly forwarding all arguments and not interpreting them, but the problem is that we have a different set of flags for each subcommand, so we don't know how to parse the arguments until we figure out the subcommand. We can likely be more clever on that line, though!

We could perhaps use the StopAtFirstFree mode of getopts to use the "base" set of flags and assume that no subcommand-specific flags like --test-args come before the subcommand. That way we could parse the arguments, learn the subcommand, then reparse the arguments with the known set of flags afterwards.

@nagisa
Copy link
Member

nagisa commented Dec 25, 2016

Or migrate to clap :)

@estebank estebank closed this Jan 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants