-
Notifications
You must be signed in to change notification settings - Fork 45
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
Ability to run a script from stdin #126
Comments
Does process substitution do what you need? $ rust-script <(echo 'println!("Hello '"$USER"'!");')
Hello gjum! |
🤔 Hm... maybe I'm holding it wrong or the inner shell is messing up the outer one but this fails: rust-script <( sed 's/PKG/ssh-openpgp-auth/g;s/KIND/shell_completions/g' <<< '//! ```cargo
//! [dependencies]
//! pkg = { path = "PKG", package = "PKG" }
//! clap_allgen = "0.1.0"
//! ```
fn main() -> Result<(), Box<dyn std::error::Error>> {
clap_allgen::render_KIND::<pkg::Commands>(
&std::env::args().collect::<Vec<_>>()[1],
)?;
Ok(())
}
' ) '/tmp/xxz' The error is:
The following works: sed 's/PKG/ssh-openpgp-auth/g;s/KIND/shell_completions/g' > .script.rs <<< '//! ```cargo
//! [dependencies]
//! pkg = { path = "PKG", package = "PKG" }
//! clap_allgen = "0.1.0"
//! ```
fn main() -> Result<(), Box<dyn std::error::Error>> {
clap_allgen::render_KIND::<pkg::Commands>(
&std::env::args().collect::<Vec<_>>()[1],
)?;
Ok(())
}
'
rust-script .script.rs '/tmp/xxz'
rm --force .script.rs Just for the record I'm modifying this file. Thanks for your time! 👋 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
I just found rust-script and it's super-great! ❤️
I'm using it to generate a small Rust script and then run it like that:
And I thought it would be convenient if I could just pipe the script directly to rust-script without saving it to file, something like that:
I've seen that there's a
--loop
option but sadly this is for writing filters not entire scripts.Would something like this be in-scope for this project?
Thanks! 👋
The text was updated successfully, but these errors were encountered: