Skip to content

Commit 302eb7b

Browse files
committed
Merge branch 'main' into pdl-263
2 parents 88cf7f8 + a19aeab commit 302eb7b

File tree

16 files changed

+72
-303
lines changed

16 files changed

+72
-303
lines changed

pdl-live-react/src-tauri/src/cli/setup.rs renamed to pdl-live-react/src-tauri/src/cli.rs

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ use ::std::path::Path;
33
use tauri_plugin_cli::CliExt;
44
use urlencoding::encode;
55

6-
use crate::cli::run;
76
use crate::compile;
8-
use crate::gui::setup as gui_setup;
7+
use crate::gui::new_window;
8+
use crate::pdl::run::run_pdl_program;
99

1010
#[cfg(desktop)]
11-
pub fn cli(app: &mut tauri::App) -> Result<bool, Box<dyn ::std::error::Error>> {
11+
pub fn setup(app: &mut tauri::App) -> Result<bool, Box<dyn ::std::error::Error>> {
1212
app.handle().plugin(tauri_plugin_cli::init())?;
1313

1414
// `matches` here is a Struct with { args, subcommand }.
@@ -49,7 +49,7 @@ pub fn cli(app: &mut tauri::App) -> Result<bool, Box<dyn ::std::error::Error>> {
4949
_ => Err(Box::from("Unsupported compile command")),
5050
}
5151
}
52-
"run" => run::run_pdl_program(
52+
"run" => run_pdl_program(
5353
subcommand_args
5454
.get("source")
5555
.and_then(|a| a.value.as_str())
@@ -59,19 +59,14 @@ pub fn cli(app: &mut tauri::App) -> Result<bool, Box<dyn ::std::error::Error>> {
5959
subcommand_args.get("stream").and_then(|a| a.value.as_str()),
6060
)
6161
.and_then(|()| Ok(true)),
62-
"view" => gui_setup(
62+
"view" => new_window(
6363
app.handle().clone(),
64-
subcommand_args
65-
.get("trace")
66-
.and_then(|a| {
67-
Some(
68-
Path::new("#/local")
69-
.join(encode(&a.value.as_str().expect("trace arg is string")).as_ref())
70-
.display()
71-
.to_string(),
72-
)
73-
})
74-
.expect("valid positional trace arg"),
64+
subcommand_args.get("trace").and_then(|a| {
65+
Some(
66+
Path::new("#/local")
67+
.join(encode(&a.value.as_str().expect("trace arg is string")).as_ref()),
68+
)
69+
}),
7570
)
7671
.and_then(|()| Ok(false)),
7772
_ => Err(Box::from("Unsupported command")),

pdl-live-react/src-tauri/src/cli/mod.rs

Lines changed: 0 additions & 2 deletions
This file was deleted.

pdl-live-react/src-tauri/src/compile/beeai.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ use serde::Deserialize;
1111
use serde_json::{from_reader, json, to_string, Value};
1212
use tempfile::Builder;
1313

14-
use crate::interpreter::ast::{PdlBaseType, PdlBlock, PdlOptionalType, PdlParser, PdlType};
15-
use crate::interpreter::pip::pip_install_if_needed;
16-
use crate::interpreter::requirements::BEEAI_FRAMEWORK;
14+
use crate::pdl::ast::{PdlBaseType, PdlBlock, PdlOptionalType, PdlParser, PdlType};
15+
use crate::pdl::pip::pip_install_if_needed;
16+
use crate::pdl::requirements::BEEAI_FRAMEWORK;
1717

1818
macro_rules! zip {
1919
($x: expr) => ($x);
Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
1+
use ::std::path::PathBuf;
12
use tauri::WebviewWindowBuilder;
23

3-
pub fn setup(app: tauri::AppHandle, path: String) -> Result<(), Box<dyn ::std::error::Error>> {
4-
WebviewWindowBuilder::new(&app, "main", tauri::WebviewUrl::App(path.into()))
5-
.title("Prompt Declaration Language")
6-
.zoom_hotkeys_enabled(true)
7-
.inner_size(1400.0, 1050.0)
8-
.build()?;
4+
pub fn new_window(
5+
app: tauri::AppHandle,
6+
path: Option<PathBuf>,
7+
) -> Result<(), Box<dyn ::std::error::Error>> {
8+
WebviewWindowBuilder::new(
9+
&app,
10+
"main",
11+
tauri::WebviewUrl::App(path.unwrap_or("".into())),
12+
)
13+
.title("Prompt Declaration Language")
14+
.zoom_hotkeys_enabled(true)
15+
.inner_size(1400.0, 1050.0)
16+
.build()?;
917
Ok(())
1018
}

pdl-live-react/src-tauri/src/lib.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,18 @@ mod cli;
55
mod commands;
66
mod compile;
77
mod gui;
8-
mod interpreter;
8+
mod pdl;
9+
mod util;
910

1011
#[cfg_attr(mobile, tauri::mobile_entry_point)]
1112
pub fn run() {
1213
tauri::Builder::default()
1314
.setup(|app| {
1415
// Default to GUI if the app was opened with no CLI args.
1516
if args_os().count() <= 1 {
16-
gui::setup(app.handle().clone(), "".to_owned())
17+
gui::new_window(app.handle().clone(), None)
1718
} else {
18-
match cli::setup::cli(app) {
19+
match cli::setup(app) {
1920
Ok(true) => ::std::process::exit(0), // success with CLI
2021
Ok(false) => Ok(()), // instead, open GUI (fallthrough to the logic below)
2122
Err(s) => {

pdl-live-react/src-tauri/src/interpreter/mod.rs renamed to pdl-live-react/src-tauri/src/pdl/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ pub mod extract;
33
pub mod pip;
44
pub mod pull;
55
pub mod requirements;
6-
pub mod shasum;
6+
pub mod run;

pdl-live-react/src-tauri/src/interpreter/pip.rs renamed to pdl-live-react/src-tauri/src/pdl/pip.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use ::std::path::PathBuf;
44
use dirs::cache_dir;
55
use duct::cmd;
66

7-
use crate::interpreter::shasum;
7+
use crate::util::shasum;
88

99
#[cfg(desktop)]
1010
pub async fn pip_install_if_needed(

pdl-live-react/src-tauri/src/interpreter/pull.rs renamed to pdl-live-react/src-tauri/src/pdl/pull.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use duct::cmd;
44
use rayon::prelude::*;
55
use yaml_rust2::{Yaml, YamlLoader};
66

7-
use crate::interpreter::extract;
7+
use crate::pdl::extract;
88

99
/// Read the given filesystem path and produce a potentially multi-document Yaml
1010
fn from_path(path: &str) -> Result<Vec<Yaml>, Error> {

0 commit comments

Comments
 (0)