You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 runs cargo 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 have cargo-expand installed I could write something like rust-script --cargo-cmd expand script.rs. This is more flexible (e.g. I could also use it to run cargo clippy or cargo check if I'm just trying to see any warnings or errors), though it does require the user to install cargo-expand first.
With this approach the --test and --bench flags could potentially be obsoleted in favor of just specifying the test and bench 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 as rust-script [OPTIONS] [--] [script]... but if I actually run rust-script foo bar it treats foo as a script and ignores bar completely (also it indicates script as being optional and yet it is not). This could be updated to the syntax rust-script [OPTIONS] [--] [cmd] <script> instead such that I could write rust-script test foo.rs to run cargo test or rust-script expand foo.rs to run cargo expand.
The text was updated successfully, but these errors were encountered:
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.
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
.The text was updated successfully, but these errors were encountered: