Skip to content

Commit 615b7ef

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

File tree

5 files changed

+16
-9
lines changed

5 files changed

+16
-9
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ gear.png
2222
in_obj.png
2323
output.png
2424
/source.*
25+
a_2x6_mounting_plate.kcl

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "zoo"
3-
version = "0.2.94"
3+
version = "0.2.95"
44
edition = "2021"
55
build = "build.rs"
66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

src/cmd_kcl.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ impl crate::cmd::Command for CmdKcl {
7070
#[clap(verbatim_doc_comment)]
7171
pub struct CmdKclExport {
7272
/// The path to the input kcl file to export.
73+
/// This can also be the path to a directory containing a main.kcl file.
7374
/// If you pass `-` as the path, the file will be read from stdin.
7475
#[clap(name = "input", required = true)]
7576
pub input: std::path::PathBuf,
@@ -173,6 +174,7 @@ impl crate::cmd::Command for CmdKclExport {
173174
#[clap(verbatim_doc_comment)]
174175
pub struct CmdKclFormat {
175176
/// The path to the input kcl file to format.
177+
/// This can also be the path to a directory containing a main.kcl file.
176178
/// If you pass `-` as the path, the file will be read from stdin.
177179
#[clap(name = "input", required = true)]
178180
pub input: std::path::PathBuf,
@@ -252,6 +254,7 @@ impl crate::cmd::Command for CmdKclFormat {
252254
#[clap(verbatim_doc_comment)]
253255
pub struct CmdKclSnapshot {
254256
/// The path to the input kcl file to snapshot.
257+
/// This can also be the path to a directory containing a main.kcl file.
255258
/// If you pass `-` as the path, the file will be read from stdin.
256259
#[clap(name = "input", required = true)]
257260
pub input: std::path::PathBuf,
@@ -313,16 +316,11 @@ impl crate::cmd::Command for CmdKclSnapshot {
313316
};
314317

315318
// Get the contents of the input file.
316-
let filename = self
317-
.input
318-
.file_name()
319-
.map(|b| b.to_string_lossy().to_string())
320-
.unwrap_or("unknown".to_string());
321319
let (code, filepath) = ctx.get_code_and_file_path(&self.input).await?;
322320

323321
// Get the modeling settings from the project.toml if exists.
324322
let mut executor_settings = get_modeling_settings_from_project_toml(&filepath, self.src_unit.clone())?;
325-
executor_settings.replay = self.replay.then_some(filename);
323+
executor_settings.replay = self.replay.then_some(filepath.to_string_lossy().to_string());
326324

327325
let (output_file_contents, session_data) = match self.session {
328326
Some(addr) => {
@@ -401,6 +399,7 @@ impl crate::cmd::Command for CmdKclSnapshot {
401399
#[clap(verbatim_doc_comment)]
402400
pub struct CmdKclView {
403401
/// The path to the input kcl file to view.
402+
/// This can also be the path to a directory containing a main.kcl file.
404403
/// If you pass `-` as the path, the file will be read from stdin.
405404
#[clap(name = "input", required = true)]
406405
pub input: std::path::PathBuf,
@@ -561,6 +560,7 @@ fn get_output_format(
561560
#[clap(verbatim_doc_comment)]
562561
pub struct CmdKclVolume {
563562
/// The path to the input file.
563+
/// This can also be the path to a directory containing a main.kcl file.
564564
/// If you pass `-` as the path, the file will be read from stdin.
565565
#[clap(name = "input", required = true)]
566566
pub input: std::path::PathBuf,
@@ -643,6 +643,7 @@ impl crate::cmd::Command for CmdKclVolume {
643643
#[clap(verbatim_doc_comment)]
644644
pub struct CmdKclMass {
645645
/// The path to the input file.
646+
/// This can also be the path to a directory containing a main.kcl file.
646647
/// If you pass `-` as the path, the file will be read from stdin.
647648
#[clap(name = "input", required = true)]
648649
pub input: std::path::PathBuf,
@@ -739,6 +740,7 @@ impl crate::cmd::Command for CmdKclMass {
739740
#[clap(verbatim_doc_comment)]
740741
pub struct CmdKclCenterOfMass {
741742
/// The path to the input file.
743+
/// This can also be the path to a directory containing a main.kcl file.
742744
/// If you pass `-` as the path, the file will be read from stdin.
743745
#[clap(name = "input", required = true)]
744746
pub input: std::path::PathBuf,
@@ -821,6 +823,7 @@ impl crate::cmd::Command for CmdKclCenterOfMass {
821823
#[clap(verbatim_doc_comment)]
822824
pub struct CmdKclDensity {
823825
/// The path to the input file.
826+
/// This can also be the path to a directory containing a main.kcl file.
824827
/// If you pass `-` as the path, the file will be read from stdin.
825828
#[clap(name = "input", required = true)]
826829
pub input: std::path::PathBuf,
@@ -917,6 +920,7 @@ impl crate::cmd::Command for CmdKclDensity {
917920
#[clap(verbatim_doc_comment)]
918921
pub struct CmdKclSurfaceArea {
919922
/// The path to the input file.
923+
/// This can also be the path to a directory containing a main.kcl file.
920924
/// If you pass `-` as the path, the file will be read from stdin.
921925
#[clap(name = "input", required = true)]
922926
pub input: std::path::PathBuf,
@@ -993,6 +997,7 @@ impl crate::cmd::Command for CmdKclSurfaceArea {
993997
#[clap(verbatim_doc_comment)]
994998
pub struct CmdKclLint {
995999
/// The path to the input file.
1000+
/// This can also be the path to a directory containing a main.kcl file.
9961001
/// If you pass `-` as the path, the file will be read from stdin.
9971002
#[clap(name = "input", required = true)]
9981003
pub input: std::path::PathBuf,
@@ -1130,7 +1135,8 @@ fn get_modeling_settings_from_project_toml(
11301135
if let Some(project_toml) = project_toml {
11311136
let project_toml = std::fs::read_to_string(&project_toml)?;
11321137
let project_toml: kcl_lib::ProjectConfiguration = toml::from_str(&project_toml)?;
1133-
let settings: kcl_lib::ExecutorSettings = project_toml.settings.modeling.into();
1138+
let mut settings: kcl_lib::ExecutorSettings = project_toml.settings.modeling.into();
1139+
settings.with_current_file(input.into());
11341140
// Make sure if they gave a command line flag, it tells them they don't match.
11351141
if let Some(src_unit) = src_unit {
11361142
let units: kittycad::types::UnitLength = settings.units.into();

tests/walkie-talkie.png

66.6 KB
Loading

0 commit comments

Comments
 (0)