From b948c0d8067250014cfa286538e49c419d0acb93 Mon Sep 17 00:00:00 2001 From: Lino Le Van <11367844+lino-levan@users.noreply.github.com> Date: Fri, 19 Jan 2024 10:56:37 -0800 Subject: [PATCH] chore: rename runtime to target --- crates/cli/src/main.rs | 15 +++++++++------ examples/interop/deno.blight | 7 +++++++ 2 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 examples/interop/deno.blight diff --git a/crates/cli/src/main.rs b/crates/cli/src/main.rs index 7385f4c91b35d1d32c21ca4c9923576b76b40869..0e1507c1329d2075ae77dcb59b09b203698b5400 100644 --- a/crates/cli/src/main.rs +++ b/crates/cli/src/main.rs @@ -26,12 +26,15 @@ enum Commands { // Whether to output to stdout instead of a file #[arg(long, default_value_t = false)] stdout: bool, + /// What javascript runtime to compile to + #[arg(short, long, default_value = "deno")] + target: String, }, Run { file: PathBuf, - /// What javascript runtime to use + /// What javascript runtime to compile to and use #[arg(short, long, default_value = "deno")] - runtime: String, + target: String, }, } @@ -63,7 +66,7 @@ fn main() -> Result<()> { let cli = Cli::parse(); match cli.command { - Commands::Compile { file, stdout } => { + Commands::Compile { file, stdout, target: _ } => { let contents = std::fs::read_to_string(file.clone()).unwrap(); let result = transpile(contents.clone())?; @@ -73,14 +76,14 @@ fn main() -> Result<()> { std::fs::write(file.with_extension("js"), result).unwrap(); } } - Commands::Run { file, runtime } => { + Commands::Run { file, target } => { let contents = std::fs::read_to_string(file.clone()).unwrap(); let result = transpile(contents.clone())?; let mut temp_file = std::env::temp_dir(); temp_file.push("temp.js"); std::fs::write(temp_file.clone(), result).unwrap(); - let rt = get_runtime(&runtime); + let rt = get_runtime(&target); match rt.as_str() { "deno" => { @@ -108,7 +111,7 @@ fn main() -> Result<()> { println!("{}", String::from_utf8_lossy(&output.stdout)); } _ => { - println!("Unknown runtime: {}", runtime); + println!("Unknown runtime: {}", target); } } } diff --git a/examples/interop/deno.blight b/examples/interop/deno.blight new file mode 100644 index 0000000000000000000000000000000000000000..9f6b1157fa6bb3f64d7f1ffbdc0f086372559925 --- /dev/null +++ b/examples/interop/deno.blight @@ -0,0 +1,7 @@ +let writeTextFile: any = @raw("Deno.writeTextFile"); + +fn x() -> string { + "hello" +} + +writeTextFile("hello.txt", x()); -- 2.54.0