lunatic-solutions / lunatic

Lunatic is an Erlang-inspired runtime for WebAssembly
https://lunatic.solutions
Apache License 2.0
4.62k stars 138 forks source link

Run wasm default option #178

Closed pinkforest closed 1 year ago

pinkforest commented 1 year ago
bkolobara commented 1 year ago

Great work on figuring this out! There is also this part when running tests that now needs to receive an optional run: https://github.com/lunatic-solutions/lunatic/blob/main/src/mode/cargo_test.rs#L15-L18

Can this also be made optional?

pinkforest commented 1 year ago

I found a better way - let me know if you liked the old better - now it handles --flags proper w/ the power of regex :)

Now it's

$ lunatic --bench

Usage: lunatic run --bench <PATH> [WASM_ARGS]...

$ lunatic --bench target/wasm32-wasi/debug/yaws.wasm

Listening on addr: 127.0.0.1:9999

$ lunatic --dir . target/wasm32-wasi/debug/yaws.wasm

Listening on addr: 127.0.0.1:9999

$ lunatic target/wasm32-wasi/debug/yaws.wasm

Listening on addr: 127.0.0.1:9999

$ lunatic errororor

error: The subcommand 'errororor' wasn't recognized

Usage: lunatic-runtime <COMMAND>

For more information, try '--help'.

$ lunatic --fff errororor

error: unexpected argument '--fff' found

Usage: lunatic <COMMAND>

For more information, try '--help'.

$ lunatic run target/wasm32-wasi/debug/yaws.wasm

Listening on addr: 127.0.0.1:9999
pinkforest commented 1 year ago

Can this also be made optional?

I adjusted the detection that was out there and now it works in both under cargo test and lunatic run :tada:

bkolobara commented 1 year ago

This looks good to me. My only worry is that we will need to remember to extend the regex every time we add an additional argument to run, but this shouldn't be a big issue and I'm going to merge this as is.

pinkforest commented 1 year ago

remember to extend the regex every time we add an additional argument to run

Could always have a regex with ^- then as no subcommand start with a dash