Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 22 additions & 17 deletions pdl-live-react/src-tauri/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use urlencoding::encode;

use crate::compile;
use crate::gui::new_window;
use crate::pdl::interpreter::run_file_sync as run;
use crate::pdl::interpreter::{load_scope, run_file_sync, RunOptions};

#[cfg(desktop)]
pub fn setup(app: &mut tauri::App) -> Result<bool, Box<dyn ::std::error::Error>> {
Expand Down Expand Up @@ -49,26 +49,31 @@ pub fn setup(app: &mut tauri::App) -> Result<bool, Box<dyn ::std::error::Error>>
_ => Err(Box::from("Unsupported compile command")),
}
}
"run" => run(
"run" => run_file_sync(
subcommand_args
.get("source")
.and_then(|a| a.value.as_str())
.expect("valid positional source arg"),
subcommand_args.get("trace").and_then(|a| a.value.as_str()),
subcommand_args.get("data").and_then(|a| a.value.as_str()),
subcommand_args
.get("data-file")
.and_then(|a| a.value.as_str()),
subcommand_args
.get("debug")
.and_then(|a| a.value.as_bool())
.or(Some(false))
== Some(true),
subcommand_args
.get("no-stream")
.and_then(|a| a.value.as_bool())
.or(Some(false))
== Some(false),
RunOptions {
trace: subcommand_args.get("trace").and_then(|a| a.value.as_str()),
debug: subcommand_args
.get("debug")
.and_then(|a| a.value.as_bool())
.or(Some(false))
== Some(true),
stream: subcommand_args
.get("no-stream")
.and_then(|a| a.value.as_bool())
.or(Some(false))
== Some(false),
},
load_scope(
subcommand_args.get("data").and_then(|a| a.value.as_str()),
subcommand_args
.get("data-file")
.and_then(|a| a.value.as_str()),
None,
)?,
)
.and_then(|_trace| Ok(true)),
"view" => new_window(
Expand Down
4 changes: 2 additions & 2 deletions pdl-live-react/src-tauri/src/commands/interpreter.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::pdl::interpreter::{pretty_print, run_string};

#[tauri::command]
pub async fn run_pdl_program(program: String, debug: bool) -> Result<String, String> {
let (_, messages, _) = run_string(&program, debug)
pub async fn run_pdl_program(program: String) -> Result<String, String> {
let (_, messages, _) = run_string(&program, Default::default(), Default::default())
.await
.map_err(|err| err.to_string())?;

Expand Down
Loading