-
Notifications
You must be signed in to change notification settings - Fork 29
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
impemented --runtime-args flag #19
base: main
Are you sure you want to change the base?
Conversation
@@ -177,9 +177,11 @@ fn rmain(config: &mut Config) -> Result<()> { | |||
|
|||
for run in build.runs.iter() { | |||
config.status("Running", &format!("`{}`", run.join(" "))); | |||
let (runtime_args, binary_args) = utils::split_args(run); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the way we'll want to handle this is do some option parsing before the --
argument. Ideally this would use a full-fledged option parser, but we'll want to recognize --runtime-args
as an argument to cargo wasi run
, but not forward the argument to cargo run
.
Put another way, --runtime-args
is a flag to cargo wasi run
, which means it needs to go before the --
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally this would use a full-fledged option parser
which one would you suggest to use here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have one in mind per se, I haven't looked into doing this yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just pushed an example using structopt
. What do you think about it? Is it viable to continue this way?
So the main thing to handle here is definitely the option parsing. We'll want to be careful to not do this with simple string iteration but to instead us some form of an argument parser. For example, although weird, something could look like The easiest, although still difficult, solution that I can think of is to copy Cargo's help text and option parsing into |
This pr adds the ability to pass arguments to runtime using
--runtime-args
flag.At the moment I made a naive implementation of
split_args
function to separate arguments intended for binary from ones intended for runtime. Is it planned to use a library likeclap
orstructopt
? It may simplify the work with arguments a bitCloses #17