Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
Signed-off-by: Jess Frazelle <[email protected]>
  • Loading branch information
jessfraz committed Feb 27, 2025
1 parent d7107dd commit f351db6
Show file tree
Hide file tree
Showing 12 changed files with 330 additions and 503 deletions.
317 changes: 228 additions & 89 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ git_rev = "0.1.0"
heck = "0.5.0"
http = "1"
itertools = "0.12.1"
kcl-lib = { version = "0.2.39", features = ["disable-println"] }
kcl-test-server = "0.1.39"
#kcl-lib = { version = "0.2.40", features = ["disable-println"] }
kcl-lib = { path = "../modeling-app/src/wasm-lib/kcl" }
kcl-test-server = "0.1.40"
kittycad = { version = "0.3.30", features = ["clap", "tabled", "requests", "retry"] }
kittycad-modeling-cmds = { version = "0.2.100", features = ["websocket", "convert_client_crate", "tabled"] }
log = "0.4.25"
miette = { version = "7.5.0", features = ["fancy"] }
nu-ansi-term = "0.50.1"
num-traits = "0.2.19"
oauth2 = "4.4.2"
Expand Down
15 changes: 11 additions & 4 deletions src/cmd_kcl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,17 @@ impl crate::cmd::Command for CmdKclExport {
let settings = get_modeling_settings_from_project_toml(&filepath)?;

let program = kcl_lib::Program::parse_no_errs(&code)
.map_err(|err| kcl_error_fmt::KclError::new(code.to_string(), err))?;
.map_err(|err| kcl_error_fmt::into_miette_for_parse(&filepath.display().to_string(), &code, err))?;
let meta_settings = program.meta_settings()?.unwrap_or_default();
let units: kcl_lib::UnitLength = meta_settings.default_length_units.into();

let mut state = kcl_lib::ExecState::new(&settings);
let client = ctx.api_client("")?;
let ectx = kcl_lib::ExecutorContext::new(&client, settings).await?;
let session_data = ectx
.run(&program, &mut state)
.run_with_ui_outputs(&program, &mut state)
.await
.map_err(|err| kcl_error_fmt::KclError::new(code.to_string(), err))?
.map_err(|err| kcl_error_fmt::into_miette(&code, err))?
.1;

// Zoom on the object.
Expand All @@ -152,7 +152,7 @@ impl crate::cmd::Command for CmdKclExport {
}),
)
.await
.map_err(|err| kcl_error_fmt::KclError::new(code.to_string(), err))?;
.map_err(|err| kcl_error_fmt::into_miette_for_parse(&filepath.display().to_string(), &code, err))?;

if let kittycad_modeling_cmds::websocket::OkWebSocketResponseData::Export { files } = resp {
// Save the files to our export directory.
Expand Down Expand Up @@ -355,6 +355,7 @@ impl crate::cmd::Command for CmdKclSnapshot {
let (resp, session_data) = ctx
.send_kcl_modeling_cmd(
"",
&filepath.display().to_string(),
&code,
kittycad_modeling_cmds::ModelingCmd::TakeSnapshot(kittycad_modeling_cmds::TakeSnapshot {
format: output_format,
Expand Down Expand Up @@ -429,6 +430,7 @@ impl crate::cmd::Command for CmdKclView {
let (resp, _session_data) = ctx
.send_kcl_modeling_cmd(
"",
&filepath.display().to_string(),
&code,
kittycad_modeling_cmds::ModelingCmd::TakeSnapshot(kittycad_modeling_cmds::TakeSnapshot {
format: kittycad_modeling_cmds::ImageFormat::Png,
Expand Down Expand Up @@ -583,6 +585,7 @@ impl crate::cmd::Command for CmdKclVolume {
let (resp, session_data) = ctx
.send_kcl_modeling_cmd(
"",
&filepath.display().to_string(),
&code,
kittycad_modeling_cmds::ModelingCmd::Volume(kittycad_modeling_cmds::Volume {
entity_ids: vec![], // get whole model
Expand Down Expand Up @@ -667,6 +670,7 @@ impl crate::cmd::Command for CmdKclMass {
let (resp, session_data) = ctx
.send_kcl_modeling_cmd(
"",
&filepath.display().to_string(),
&code,
kittycad_modeling_cmds::ModelingCmd::Mass(kittycad_modeling_cmds::Mass {
entity_ids: vec![], // get whole model
Expand Down Expand Up @@ -741,6 +745,7 @@ impl crate::cmd::Command for CmdKclCenterOfMass {
let (resp, session_data) = ctx
.send_kcl_modeling_cmd(
"",
&filepath.display().to_string(),
&code,
kittycad_modeling_cmds::ModelingCmd::CenterOfMass(kittycad_modeling_cmds::CenterOfMass {
entity_ids: vec![], // get whole model
Expand Down Expand Up @@ -825,6 +830,7 @@ impl crate::cmd::Command for CmdKclDensity {
let (resp, session_data) = ctx
.send_kcl_modeling_cmd(
"",
&filepath.display().to_string(),
&code,
kittycad_modeling_cmds::ModelingCmd::Density(kittycad_modeling_cmds::Density {
entity_ids: vec![], // get whole model
Expand Down Expand Up @@ -899,6 +905,7 @@ impl crate::cmd::Command for CmdKclSurfaceArea {
let (resp, session_data) = ctx
.send_kcl_modeling_cmd(
"",
&filepath.display().to_string(),
&code,
kittycad_modeling_cmds::ModelingCmd::SurfaceArea(kittycad_modeling_cmds::SurfaceArea {
entity_ids: vec![], // get whole model
Expand Down
11 changes: 6 additions & 5 deletions src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,21 +136,22 @@ impl Context<'_> {
pub async fn send_kcl_modeling_cmd(
&self,
hostname: &str,
filename: &str,
code: &str,
cmd: kittycad_modeling_cmds::ModelingCmd,
settings: kcl_lib::ExecutorSettings,
) -> Result<(OkWebSocketResponseData, Option<ModelingSessionData>)> {
let client = self.api_client(hostname)?;

let program =
kcl_lib::Program::parse_no_errs(code).map_err(|err| kcl_error_fmt::KclError::new(code.to_string(), err))?;
let program = kcl_lib::Program::parse_no_errs(code)
.map_err(|err| kcl_error_fmt::into_miette_for_parse(filename, &code, err))?;

let mut state = kcl_lib::ExecState::new(&settings);
let ctx = kcl_lib::ExecutorContext::new(&client, settings).await?;
let session_data = ctx
.run(&program, &mut state)
.run_with_ui_outputs(&program, &mut state)
.await
.map_err(|err| kcl_error_fmt::KclError::new(code.to_string(), err))?
.map_err(|err| kcl_error_fmt::into_miette(&code, err))?
.1;

// Zoom on the object.
Expand All @@ -170,7 +171,7 @@ impl Context<'_> {
.engine
.send_modeling_cmd(uuid::Uuid::new_v4(), kcl_lib::SourceRange::default(), &cmd)
.await
.map_err(|err| kcl_error_fmt::KclError::new(code.to_string(), err))?;
.map_err(|err| kcl_error_fmt::into_miette_for_parse(filename, &code, err))?;
Ok((resp, session_data))
}

Expand Down
Loading

0 comments on commit f351db6

Please sign in to comment.