Skip to content

Instantly share code, notes, and snippets.

@gauravssnl
Forked from badboy/hello-world.rs
Created January 8, 2023 11:36
Show Gist options
  • Save gauravssnl/742cef04808e0b83d20bf2b9cd9f9dcd to your computer and use it in GitHub Desktop.
Save gauravssnl/742cef04808e0b83d20bf2b9cd9f9dcd to your computer and use it in GitHub Desktop.
Poor dev's Rust Compiler
fn main() {
println!("Hello World!");
}
#!/bin/bash
# Requires `jq`, because I am lazy
# jq: https://stedolan.github.io/jq/
[ $# -ne 1 ] && echo "Usage: $(basename $0) file.rs" && exit
echo "{\"channel\":\"stable\",\"crateType\":\"bin\",\"mode\":\"debug\",\"tests\":false,\"code\":\"$(sed -e 's/"/\\"/g' -e 's/$/\\n/g' $1|tr -d '\n')\"}" \
| curl -skH"Content-Type:application/json" https://play.rust-lang.org/execute -d@- \
| jq .stdout \
| sed -e 's/^"//' -e 's/"$//' -e 's/\\n/\n/g' | sed '/^$/d'
#!/bin/bash
[ $# -ne 1 ] && echo "Usage: $(basename $0) file.rs" && exit
echo "{\"channel\":\"stable\",\"crateType\":\"bin\",\"mode\":\"debug\",\"tests\":false,\"code\":\"$(sed -e 's/"/\\"/g' -e 's/$/\\n/g' $1|tr -d '\n')\"}" | curl -skH"Content-Type:application/json" https://play.rust-lang.org/execute -d@- | jq .stdout | sed -e 's/^"//' -e 's/"$//' -e 's/\\n/\n/g' | sed '/^$/d'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment