@@ -70,6 +70,7 @@ impl crate::cmd::Command for CmdKcl {
7070#[ clap( verbatim_doc_comment) ]
7171pub 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) ]
174175pub 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) ]
253255pub 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) ]
402400pub 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) ]
562561pub 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) ]
644644pub 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) ]
740741pub 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) ]
822824pub 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) ]
918921pub 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) ]
994998pub 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 ( ) ;
0 commit comments