diff --git a/components/clarinet-cli/src/frontend/cli.rs b/components/clarinet-cli/src/frontend/cli.rs index 49a79ac7a..d6997aee5 100644 --- a/components/clarinet-cli/src/frontend/cli.rs +++ b/components/clarinet-cli/src/frontend/cli.rs @@ -1205,6 +1205,8 @@ pub fn main() { let output = formatter.format(source); if !cmd.dry_run { let _ = overwrite_formatted(file_path, output); + } else { + println!("{}", output); } } } @@ -1222,13 +1224,10 @@ pub fn main() { } fn overwrite_formatted(file_path: &String, output: String) -> io::Result<()> { - // Open the file in write mode, overwriting existing content let mut file = fs::File::create(file_path)?; file.write_all(output.as_bytes())?; - - // flush the contents to ensure it's written immediately - file.flush() + Ok(()) } fn get_source_with_path(code_path: Option, file: Option) -> Vec<(String, String)> { @@ -1238,7 +1237,7 @@ fn get_source_with_path(code_path: Option, file: Option) -> Vec< // Collect file paths and load source code let files: Vec = match file { - Some(file_name) => vec![format!("{}/{}", path, file_name)], + Some(file_name) => vec![format!("{}", file_name)], None => match fs::read_dir(&path) { Ok(entries) => entries .filter_map(Result::ok) @@ -1319,14 +1318,6 @@ fn load_manifest_or_warn(path: Option) -> Option { } } -fn load_clarity_code( - code_path: &Option, - file: &Option, - dry_run: bool, -) -> (Option) { - Some("".to_string()) -} - fn load_deployment_and_artifacts_or_exit( manifest: &ProjectManifest, deployment_plan_path: &Option, diff --git a/components/clarinet-format/src/formatter/mod.rs b/components/clarinet-format/src/formatter/mod.rs index 71f383dd9..84e01e7c2 100644 --- a/components/clarinet-format/src/formatter/mod.rs +++ b/components/clarinet-format/src/formatter/mod.rs @@ -48,9 +48,7 @@ impl ClarityFormatter { ASTRules::Typical, ) .unwrap(); - let output = format_source_exprs(&self.settings, &ast.expressions, ""); - println!("output: {}", output); - output + format_source_exprs(&self.settings, &ast.expressions, "") } }