Closed lilyball closed 1 year ago
Version 0.23.0 has just been released.
There the -p
/--project
parameter can be used to generate the package and print the package path, without doing any build step.
This allows things such as cargo tree --manifest-path $(rust-script -p test.rs)/Cargo.toml
or cd "$(rust-script --package script.ers)
, so should provide flexibility.
Let me know how it works!
I'd love a flag that makes this print the macro expansion of the input instead of compiling and running it. This could be done as a flag like
--macro-expand
that selects the nightly toolchain (if not otherwise set) and runscargo rustc --profile=check -- -Zunpretty=expanded
.Alternatives considered
rust-script could have a flag for simply changing the
cargo
command being run, such that if I havecargo-expand
installed I could write something likerust-script --cargo-cmd expand script.rs
. This is more flexible (e.g. I could also use it to runcargo clippy
orcargo check
if I'm just trying to see any warnings or errors), though it does require the user to installcargo-expand
first.With this approach the
--test
and--bench
flags could potentially be obsoleted in favor of just specifying thetest
andbench
cargo commands, though in this case the syntax for specifying the command should be simpler. I notice that right now rust-script lists its syntax asrust-script [OPTIONS] [--] [script]...
but if I actually runrust-script foo bar
it treatsfoo
as a script and ignoresbar
completely (also it indicates script as being optional and yet it is not). This could be updated to the syntaxrust-script [OPTIONS] [--] [cmd] <script>
instead such that I could writerust-script test foo.rs
to runcargo test
orrust-script expand foo.rs
to runcargo expand
.