Skip to content

Commit f351db6

Browse files
committed
updates
Signed-off-by: Jess Frazelle <github@jessfraz.com>
1 parent d7107dd commit f351db6

File tree

12 files changed

+330
-503
lines changed

12 files changed

+330
-503
lines changed

Cargo.lock

Lines changed: 228 additions & 89 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@ git_rev = "0.1.0"
2222
heck = "0.5.0"
2323
http = "1"
2424
itertools = "0.12.1"
25-
kcl-lib = { version = "0.2.39", features = ["disable-println"] }
26-
kcl-test-server = "0.1.39"
25+
#kcl-lib = { version = "0.2.40", features = ["disable-println"] }
26+
kcl-lib = { path = "../modeling-app/src/wasm-lib/kcl" }
27+
kcl-test-server = "0.1.40"
2728
kittycad = { version = "0.3.30", features = ["clap", "tabled", "requests", "retry"] }
2829
kittycad-modeling-cmds = { version = "0.2.100", features = ["websocket", "convert_client_crate", "tabled"] }
2930
log = "0.4.25"
31+
miette = { version = "7.5.0", features = ["fancy"] }
3032
nu-ansi-term = "0.50.1"
3133
num-traits = "0.2.19"
3234
oauth2 = "4.4.2"

src/cmd_kcl.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,17 +115,17 @@ impl crate::cmd::Command for CmdKclExport {
115115
let settings = get_modeling_settings_from_project_toml(&filepath)?;
116116

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

122122
let mut state = kcl_lib::ExecState::new(&settings);
123123
let client = ctx.api_client("")?;
124124
let ectx = kcl_lib::ExecutorContext::new(&client, settings).await?;
125125
let session_data = ectx
126-
.run(&program, &mut state)
126+
.run_with_ui_outputs(&program, &mut state)
127127
.await
128-
.map_err(|err| kcl_error_fmt::KclError::new(code.to_string(), err))?
128+
.map_err(|err| kcl_error_fmt::into_miette(&code, err))?
129129
.1;
130130

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

157157
if let kittycad_modeling_cmds::websocket::OkWebSocketResponseData::Export { files } = resp {
158158
// Save the files to our export directory.
@@ -355,6 +355,7 @@ impl crate::cmd::Command for CmdKclSnapshot {
355355
let (resp, session_data) = ctx
356356
.send_kcl_modeling_cmd(
357357
"",
358+
&filepath.display().to_string(),
358359
&code,
359360
kittycad_modeling_cmds::ModelingCmd::TakeSnapshot(kittycad_modeling_cmds::TakeSnapshot {
360361
format: output_format,
@@ -429,6 +430,7 @@ impl crate::cmd::Command for CmdKclView {
429430
let (resp, _session_data) = ctx
430431
.send_kcl_modeling_cmd(
431432
"",
433+
&filepath.display().to_string(),
432434
&code,
433435
kittycad_modeling_cmds::ModelingCmd::TakeSnapshot(kittycad_modeling_cmds::TakeSnapshot {
434436
format: kittycad_modeling_cmds::ImageFormat::Png,
@@ -583,6 +585,7 @@ impl crate::cmd::Command for CmdKclVolume {
583585
let (resp, session_data) = ctx
584586
.send_kcl_modeling_cmd(
585587
"",
588+
&filepath.display().to_string(),
586589
&code,
587590
kittycad_modeling_cmds::ModelingCmd::Volume(kittycad_modeling_cmds::Volume {
588591
entity_ids: vec![], // get whole model
@@ -667,6 +670,7 @@ impl crate::cmd::Command for CmdKclMass {
667670
let (resp, session_data) = ctx
668671
.send_kcl_modeling_cmd(
669672
"",
673+
&filepath.display().to_string(),
670674
&code,
671675
kittycad_modeling_cmds::ModelingCmd::Mass(kittycad_modeling_cmds::Mass {
672676
entity_ids: vec![], // get whole model
@@ -741,6 +745,7 @@ impl crate::cmd::Command for CmdKclCenterOfMass {
741745
let (resp, session_data) = ctx
742746
.send_kcl_modeling_cmd(
743747
"",
748+
&filepath.display().to_string(),
744749
&code,
745750
kittycad_modeling_cmds::ModelingCmd::CenterOfMass(kittycad_modeling_cmds::CenterOfMass {
746751
entity_ids: vec![], // get whole model
@@ -825,6 +830,7 @@ impl crate::cmd::Command for CmdKclDensity {
825830
let (resp, session_data) = ctx
826831
.send_kcl_modeling_cmd(
827832
"",
833+
&filepath.display().to_string(),
828834
&code,
829835
kittycad_modeling_cmds::ModelingCmd::Density(kittycad_modeling_cmds::Density {
830836
entity_ids: vec![], // get whole model
@@ -899,6 +905,7 @@ impl crate::cmd::Command for CmdKclSurfaceArea {
899905
let (resp, session_data) = ctx
900906
.send_kcl_modeling_cmd(
901907
"",
908+
&filepath.display().to_string(),
902909
&code,
903910
kittycad_modeling_cmds::ModelingCmd::SurfaceArea(kittycad_modeling_cmds::SurfaceArea {
904911
entity_ids: vec![], // get whole model

src/context.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,21 +136,22 @@ impl Context<'_> {
136136
pub async fn send_kcl_modeling_cmd(
137137
&self,
138138
hostname: &str,
139+
filename: &str,
139140
code: &str,
140141
cmd: kittycad_modeling_cmds::ModelingCmd,
141142
settings: kcl_lib::ExecutorSettings,
142143
) -> Result<(OkWebSocketResponseData, Option<ModelingSessionData>)> {
143144
let client = self.api_client(hostname)?;
144145

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

148149
let mut state = kcl_lib::ExecState::new(&settings);
149150
let ctx = kcl_lib::ExecutorContext::new(&client, settings).await?;
150151
let session_data = ctx
151-
.run(&program, &mut state)
152+
.run_with_ui_outputs(&program, &mut state)
152153
.await
153-
.map_err(|err| kcl_error_fmt::KclError::new(code.to_string(), err))?
154+
.map_err(|err| kcl_error_fmt::into_miette(&code, err))?
154155
.1;
155156

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

0 commit comments

Comments
 (0)