-
Notifications
You must be signed in to change notification settings - Fork 16
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
feat: expose Args
and new run_wasm_with_css_with_args
#37
Conversation
The current state of this PR is to expose a new constructor for
|
Oh, oof, sorry, accidental close. 😅 |
Hi, thanks for the PR, I will review this and #36 holistically when I get the chance. Hopefully you are able to operate off a git fork for a while and this doesnt block your work. |
@rukai: No problem at all. Wishing you well in the meantime! |
Finally got around to sitting and thinking about this. I'm thinking we could reimplement run_wasm_with_css something like this: pub fn run_wasm_with_css(css: &str) {
let args = match Args::from_env() {
Ok(args) => args,
Err(err) => {
println!("{}\n\n{}", err, HELP);
return;
}
};
if args.help {
println!("{}", HELP);
return;
}
RunWasm::builder()
.with_css(css)
.with_host(args.host)
.with_port(args.port)
.with_profile(args.profile)
.with_cargo_flags(args.cargo_flags) // args like --profile are inserted by RunWasm from with_profile and do not need to be specified here.
// TODO: and every other flag we need
.run()
} This will maintain both From there we can expose
Additionally this builder would end up being a suitable place to put the custom html logic desired by
I am cautious about the need for proper error handling as this is simply a dev tool for previewing wasm and not suitable as part of a proper deployment stack. But! if we can achieve this without regressing on the usefulness of errors to a user who just unwraps the error then I am happy to land such a change. I dont want to land this PR as is because exposing |
@rukai: I think a builder interface for arguments is a great direction. I'm happy to migrate over to it once it's ready! I'm not sure when I would be able to contribute it within the next month, but I might be able to author it in less than a couple of months. 🤔 RE: parsing arguments: I think it might be useful to offer an opaque API (perhaps over an iterator of Otherwise, it might be nice to make the CLI parsing feature-gated, too, to cut out another dependency. But that should be a separate issue, I suppose, as follow-up afterwards. :) |
Closing in favour of #40 |
It's currently impossible to embed
cargo-run-wasm
as a library unless one dedicates their entire command line interface to be forwarded to the library. This doesn't compose very well, sadly. We inwgpu
would really like to be able to use this as a subcommand in a newcargo xtask
flow (see gfx-rs/wgpu#3844 for more details).More details on the current state of this PR: #37 (comment)