Skip to content

Commit

Permalink
Merge pull request #274 from michaelb/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
michaelb authored Jan 16, 2024
2 parents b2b6f13 + 001be91 commit 0079f9c
Show file tree
Hide file tree
Showing 28 changed files with 82 additions and 52 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## v1.3.11
- Support compiler flags for C++ (courtesy of @jonathanffon) and all other languages
- Scripts use \cat instead of /bin/cat (courtesy of @GaetanLepage)

## v1.3.10
- Fix missing documentation in the online wiki
- Fix interpreters broken when they were not explicitely the default for their filetype
Expand Down
50 changes: 25 additions & 25 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sniprun"
version = "1.3.10"
version = "1.3.11"
authors = ["michaelb <[email protected]>"]
rust-version = "1.65"
edition = "2018"
Expand Down
5 changes: 4 additions & 1 deletion doc/sources/common_options.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,16 @@ interpreter_options = {
interpreter = "python3.9"
}
Rust_original = {
compiler = "/home/user/bin/rustc-patched"
compiler = "/home/user/bin/rustc-patched -Zlocation-detail=none"
}
},
```

You can see what interpreters/compilers are being used at any time by watching sniprun's log for the line
"using compiler XXXX" or "using interpreter XXXX" when you run a snippet.
While options can (generally) be added to these interpreters/compilers strings, mind that some options are often already passed, and
sometimes mandatory (ex: "-o main_file_name", "--nologo") and whatever is added can mess up the format
sniprun internally expect, or be straight out incompatible with the formers. Be careful!

Exceptions:
- Scala_original has both interpreter and compiler keys that should be set consistently with each other
Expand Down
2 changes: 1 addition & 1 deletion doc/sources/interpreters/FSharp_fifo.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ There is a lot of thing in that script but to replicate, you just have to:

```bash
#!/bin/bash
/bin/cat pipe_in | dotnet fsi
cat pipe_in | dotnet fsi

# or replace 'dotnet fsi' by whatever you cant to try
```
Expand Down
3 changes: 2 additions & 1 deletion src/interpreters/Ada_original.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ impl Interpreter for Ada_original {
.expect("Unable to write to file for language_subname");

let compiler = Ada_original::get_compiler_or(&self.data, "gnatmake");
let output = Command::new(compiler)
let output = Command::new(compiler.split_whitespace().next().unwrap())
.args(compiler.split_whitespace().skip(1))
.arg("main")
.arg(&self.main_file_path)
.current_dir(&self.ada_work_dir)
Expand Down
3 changes: 2 additions & 1 deletion src/interpreters/Bash_original.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ impl Interpreter for Bash_original {

fn execute(&mut self) -> Result<String, SniprunError> {
let interpreter = Bash_original::get_interpreter_or(&self.data, "bash");
let output = Command::new(interpreter)
let output = Command::new(interpreter.split_whitespace().next().unwrap())
.args(interpreter.split_whitespace().skip(1))
.arg(&self.main_file_path)
.args(&self.get_data().cli_args)
.output()
Expand Down
3 changes: 2 additions & 1 deletion src/interpreters/CS_original.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ impl Interpreter for CS_original {

fn execute(&mut self) -> Result<String, SniprunError> {
let interpreter = CS_original::get_interpreter_or(&self.data, "coffee");
let output = Command::new(interpreter)
let output = Command::new(interpreter.split_whitespace().next().unwrap())
.args(interpreter.split_whitespace().skip(1))
.arg(&self.main_file_path)
.args(&self.get_data().cli_args)
.output()
Expand Down
3 changes: 2 additions & 1 deletion src/interpreters/CSharp_original.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ impl Interpreter for CSharp_original {
.expect("Unable to write to file for csharp-original");

//compile it (to the bin_path that arleady points to the rigth path)
let output = Command::new(&self.compiler)
let output = Command::new(self.compiler.split_whitespace().next().unwrap())
.args(self.compiler.split_whitespace().skip(1))
.arg(String::from("-out:") + &self.bin_path)
.arg(&self.main_file_path)
.output()
Expand Down
3 changes: 2 additions & 1 deletion src/interpreters/C_original.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,9 @@ impl Interpreter for C_original {
let mut _file =
File::create(&self.main_file_path).expect("Failed to create file for c-original");
write(&self.main_file_path, &self.code).expect("Unable to write to file for c-original");
let mut cmd = Command::new(&self.compiler);
let mut cmd = Command::new(self.compiler.split_whitespace().next().unwrap());
let cmd = cmd
.args(self.compiler.split_whitespace().skip(1))
.arg(&self.main_file_path)
.arg("-o")
.arg(&self.bin_path)
Expand Down
4 changes: 3 additions & 1 deletion src/interpreters/Clojure_fifo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,9 @@ impl Interpreter for Clojure_fifo {
Ok(())
}
fn execute(&mut self) -> Result<String, SniprunError> {
let output = Command::new(self.interpreter.clone())

let output = Command::new(self.interpreter.split_whitespace().next().unwrap())
.args(self.interpreter.split_whitespace().skip(1))
.arg(&self.main_file_path)
.args(&self.get_data().cli_args)
.output()
Expand Down
3 changes: 2 additions & 1 deletion src/interpreters/D_original.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ impl Interpreter for D_original {
fn execute(&mut self) -> Result<String, SniprunError> {
//run th binary and get the std output (or stderr)
let interpreter = D_original::get_interpreter_or(&self.data, "dmd");
let output = Command::new(interpreter)
let output = Command::new(interpreter.split_whitespace().next().unwrap())
.args(interpreter.split_whitespace().skip(1))
.arg("-run")
.arg(&self.main_file_path)
.output()
Expand Down
3 changes: 2 additions & 1 deletion src/interpreters/Elixir_original.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ impl Interpreter for Elixir_original {
}
fn execute(&mut self) -> Result<String, SniprunError> {
let interpreter = Elixir_original::get_interpreter_or(&self.data, "elixir");
let output = Command::new(interpreter)
let output = Command::new(interpreter.split_whitespace().next().unwrap())
.args(interpreter.split_whitespace().skip(1))
.arg(&self.main_file_path)
.args(&self.get_data().cli_args)
.output()
Expand Down
3 changes: 2 additions & 1 deletion src/interpreters/Go_original.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,8 @@ impl Interpreter for Go_original {
write(&self.main_file_path, &self.code).expect("Unable to write to file for go-original");

//compile it (to the bin_path that arleady points to the rigth path)
let output = Command::new(&self.compiler)
let output = Command::new(self.compiler.split_whitespace().next().unwrap())
.args(self.compiler.split_whitespace().skip(1))
.arg("build")
.arg("-o")
.arg(&self.go_work_dir)
Expand Down
3 changes: 2 additions & 1 deletion src/interpreters/Haskell_original.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ impl Interpreter for Haskell_original {
&self.main_file_path, &self.bin_path
);
let compiler = Haskell_original::get_compiler_or(&self.data, "ghc");
let output = Command::new(compiler)
let output = Command::new(compiler.split_whitespace().next().unwrap())
.args(compiler.split_whitespace().skip(1))
.arg("-dynamic")
.arg("-o")
.arg(self.bin_path.clone())
Expand Down
3 changes: 2 additions & 1 deletion src/interpreters/JS_TS_bun.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ impl Interpreter for JS_TS_bun {
}
}
let interpreter = JS_TS_bun::get_interpreter_or(&self.data, "bun");
let output = Command::new(interpreter)
let output = Command::new(interpreter.split_whitespace().next().unwrap())
.args(interpreter.split_whitespace().skip(1))
.arg("run")
.arg("--silent")
.args(bun_opts.split_whitespace())
Expand Down
3 changes: 2 additions & 1 deletion src/interpreters/JS_TS_deno.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@ impl Interpreter for JS_TS_deno {
fn execute(&mut self) -> Result<String, SniprunError> {
//run the binary and get the std output (or stderr)
let interpreter = JS_TS_deno::get_interpreter_or(&self.data, "deno");
let output = Command::new(interpreter)
let output = Command::new(interpreter.split_whitespace().next().unwrap())
.args(interpreter.split_whitespace().skip(1))
.arg("run")
.arg("-A")
.arg("--unstable")
Expand Down
3 changes: 2 additions & 1 deletion src/interpreters/JS_original.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ impl Interpreter for JS_original {

fn execute(&mut self) -> Result<String, SniprunError> {
let interpreter = JS_original::get_interpreter_or(&self.data, "node");
let output = Command::new(interpreter)
let output = Command::new(interpreter.split_whitespace().next().unwrap())
.args(interpreter.split_whitespace().skip(1))
.arg(&self.main_file_path)
.args(&self.get_data().cli_args)
.output()
Expand Down
3 changes: 2 additions & 1 deletion src/interpreters/Java_original.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ impl Interpreter for Java_original {

let compiler = Java_original::get_compiler_or(&self.data, "javac");
//compile it (to the bin_path that arleady points to the rigth path)
let output = Command::new(compiler)
let output = Command::new(compiler.split_whitespace().next().unwrap())
.args(compiler.split_whitespace().skip(1))
.arg("-d")
.arg(&self.java_work_dir)
.arg(&self.main_file_path)
Expand Down
3 changes: 2 additions & 1 deletion src/interpreters/Julia_original.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ impl Interpreter for Julia_original {
Ok(())
}
fn execute(&mut self) -> Result<String, SniprunError> {
let output = Command::new(&self.interpreter)
let output = Command::new(self.interpreter.split_whitespace().next().unwrap())
.args(self.interpreter.split_whitespace().skip(1))
.args(&self.interpreter_args)
.arg(&self.main_file_path)
.args(&self.get_data().cli_args)
Expand Down
3 changes: 2 additions & 1 deletion src/interpreters/Lua_original.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ impl Interpreter for Lua_original {

fn execute(&mut self) -> Result<String, SniprunError> {
let interpreter = Lua_original::get_interpreter_or(&self.data, "lua");
let output = Command::new(interpreter)
let output = Command::new(interpreter.split_whitespace().next().unwrap())
.args(interpreter.split_whitespace().skip(1))
.arg(&self.main_file_path)
.args(&self.get_data().cli_args)
.output()
Expand Down
3 changes: 2 additions & 1 deletion src/interpreters/Mathematica_original.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,8 @@ impl Interpreter for Mathematica_original {
fn execute(&mut self) -> Result<String, SniprunError> {
//run th binary and get the std output (or stderr)
let interpreter = Mathematica_original::get_interpreter_or(&self.data, "WolframKernel");
let output = Command::new(interpreter)
let output = Command::new(interpreter.split_whitespace().next().unwrap())
.args(interpreter.split_whitespace().skip(1))
.arg("-noprompt")
.arg("-script")
.arg(&self.main_file_path)
Expand Down
3 changes: 2 additions & 1 deletion src/interpreters/Python3_original.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,8 @@ impl Interpreter for Python3_original {
Ok(())
}
fn execute(&mut self) -> Result<String, SniprunError> {
let output = Command::new(&self.interpreter)
let output = Command::new(self.interpreter.split_whitespace().next().unwrap())
.args(self.interpreter.split_whitespace().skip(1))
.arg(&self.main_file_path)
.args(&self.get_data().cli_args)
.output()
Expand Down
3 changes: 2 additions & 1 deletion src/interpreters/R_original.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ impl Interpreter for R_original {

fn execute(&mut self) -> Result<String, SniprunError> {
let interpreter = R_original::get_interpreter_or(&self.data, "Rscript");
let output = Command::new(interpreter)
let output = Command::new(interpreter.split_whitespace().next().unwrap())
.args(interpreter.split_whitespace().skip(1))
.arg(&self.main_file_path)
.args(&self.get_data().cli_args)
.output()
Expand Down
3 changes: 2 additions & 1 deletion src/interpreters/Ruby_original.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ impl Interpreter for Ruby_original {

fn execute(&mut self) -> Result<String, SniprunError> {
let interpreter = Ruby_original::get_interpreter_or(&self.data, "ruby");
let output = Command::new(interpreter)
let output = Command::new(interpreter.split_whitespace().next().unwrap())
.args(interpreter.split_whitespace().skip(1))
.arg(&self.main_file_path)
.args(&self.get_data().cli_args)
.output()
Expand Down
Loading

0 comments on commit 0079f9c

Please sign in to comment.