alexcrichton opened PR #6737 from alexcrichton:easier-flags-to-wasm-program
to bytecodealliance:main
:
Currently the way we've configured argument parsing it's valid to execute a command such as:
wasmtime run foo.wasm -O
which is the same as:
wasmtime run -O foo.wasm
or otherwise all flags are attempted to be parsed as Wasmtime flags and an error is generated when they're not wasmtime flags. I've personally found this a bit confusing in the past and I find myself frequently executing:
wasmtime run -- foo.wasm -other -arguments
While this works my general impression is that many other "wrapper commands" don't behave this way and typically don't require
--
to pass flags to the target executable. This commit reconfigures argument parsing to consider any argument after the WebAssembly module itself to be an argument to the wasm program rather than an argument to Wasmtime. This means that all Wasmtime options must come between therun
command and thefoo.wasm
WebAssembly argument.<!--
Please make sure you include the following information:
If this work has been discussed elsewhere, please include a link to that
conversation. If it was discussed in an issue, just mention "issue #...".Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->
alexcrichton requested itsrainy for a review on PR #6737.
alexcrichton requested wasmtime-core-reviewers for a review on PR #6737.
alexcrichton updated PR #6737.
sunfishcode created PR review comment:
Would it be possible to move these checks for "help" etc. higher up so that they only happen if the argument comes before any "--"? So if someone really wants to run a module named "help" or whatever they could do "wasmtime -- help"?
sunfishcode submitted PR review.
alexcrichton updated PR #6737.
alexcrichton submitted PR review.
alexcrichton created PR review comment:
Good point! Clap is the one handling
--
so it's sort of hidden from us, but I think I figured out the right clap configuration to make this work. Nowwasmtime run run
will work,wasmtime run
won't work, butwasmtime -- run
will work.
sunfishcode submitted PR review.
sunfishcode submitted PR review.
sunfishcode created PR review comment:
This comment is now stale.
sunfishcode created PR review comment:
Does this mean that we can't have top-level flags, like `wasmtime --something run foo"? I don't know of a need for top-level flags, so perhaps this is fine; I'm just trying to think ahead.
alexcrichton updated PR #6737.
alexcrichton submitted PR review.
alexcrichton created PR review comment:
According to this I believe that's correct, yes.
sunfishcode submitted PR review.
sunfishcode created PR review comment:
Ok, Wasmtime's subcommands are sufficiently different from each other that I'm not too worried about it.
sunfishcode submitted PR review.
alexcrichton updated PR #6737.
alexcrichton requested wasmtime-default-reviewers for a review on PR #6737.
alexcrichton has enabled auto merge for PR #6737.
alexcrichton updated PR #6737.
alexcrichton has enabled auto merge for PR #6737.
alexcrichton updated PR #6737.
alexcrichton has enabled auto merge for PR #6737.
alexcrichton updated PR #6737.
alexcrichton has enabled auto merge for PR #6737.
alexcrichton updated PR #6737.
alexcrichton updated PR #6737.
alexcrichton has enabled auto merge for PR #6737.
alexcrichton updated PR #6737.
alexcrichton merged PR #6737.
Last updated: Dec 23 2024 at 12:05 UTC