From 618c6243c546d3010dad6ee0d45f30aba5485c96 Mon Sep 17 00:00:00 2001 From: Islon Scherer Date: Fri, 19 Sep 2025 11:28:40 +0200 Subject: [PATCH] Fix bug in format apply (#1211) --- pkl-cli/src/main/kotlin/org/pkl/cli/CliFormatterApply.kt | 2 ++ pkl-cli/src/main/kotlin/org/pkl/cli/CliFormatterCheck.kt | 1 + pkl-cli/src/main/kotlin/org/pkl/cli/CliFormatterCommand.kt | 1 + .../src/main/kotlin/org/pkl/cli/commands/FormatterCommand.kt | 2 +- 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pkl-cli/src/main/kotlin/org/pkl/cli/CliFormatterApply.kt b/pkl-cli/src/main/kotlin/org/pkl/cli/CliFormatterApply.kt index e524e78e..cd0acc71 100644 --- a/pkl-cli/src/main/kotlin/org/pkl/cli/CliFormatterApply.kt +++ b/pkl-cli/src/main/kotlin/org/pkl/cli/CliFormatterApply.kt @@ -35,12 +35,14 @@ class CliFormatterApply(cliBaseOptions: CliBaseOptions, path: Path, private val if (stat != 0) continue if (!silent && contents != formatted) { consoleWriter.write(path.toAbsolutePath().toString()) + consoleWriter.appendLine() consoleWriter.flush() } try { path.writeText(formatted, Charsets.UTF_8) } catch (e: IOException) { consoleWriter.write("Could not overwrite `$path`: ${e.message}") + consoleWriter.appendLine() consoleWriter.flush() status = 1 } diff --git a/pkl-cli/src/main/kotlin/org/pkl/cli/CliFormatterCheck.kt b/pkl-cli/src/main/kotlin/org/pkl/cli/CliFormatterCheck.kt index 3657808f..ee1059b0 100644 --- a/pkl-cli/src/main/kotlin/org/pkl/cli/CliFormatterCheck.kt +++ b/pkl-cli/src/main/kotlin/org/pkl/cli/CliFormatterCheck.kt @@ -32,6 +32,7 @@ class CliFormatterCheck(cliBaseOptions: CliBaseOptions, path: Path) : status = if (status == 0) stat else status if (contents != formatted) { consoleWriter.write(path.toAbsolutePath().toString()) + consoleWriter.appendLine() consoleWriter.flush() status = 1 } diff --git a/pkl-cli/src/main/kotlin/org/pkl/cli/CliFormatterCommand.kt b/pkl-cli/src/main/kotlin/org/pkl/cli/CliFormatterCommand.kt index e206e1c8..5bfe2753 100644 --- a/pkl-cli/src/main/kotlin/org/pkl/cli/CliFormatterCommand.kt +++ b/pkl-cli/src/main/kotlin/org/pkl/cli/CliFormatterCommand.kt @@ -39,6 +39,7 @@ constructor( return Formatter().format(contents) to 0 } catch (pe: GenericParserError) { consoleWriter.write("Could not format `$file`: $pe") + consoleWriter.appendLine() consoleWriter.flush() return "" to 1 } diff --git a/pkl-cli/src/main/kotlin/org/pkl/cli/commands/FormatterCommand.kt b/pkl-cli/src/main/kotlin/org/pkl/cli/commands/FormatterCommand.kt index e881db33..5ba34a99 100644 --- a/pkl-cli/src/main/kotlin/org/pkl/cli/commands/FormatterCommand.kt +++ b/pkl-cli/src/main/kotlin/org/pkl/cli/commands/FormatterCommand.kt @@ -66,6 +66,6 @@ class FormatterApplyCommand : BaseCommand(name = "apply", helpLink = helpLink) { .flag() override fun run() { - CliFormatterApply(baseOptions.baseOptions(emptyList()), path, silent) + CliFormatterApply(baseOptions.baseOptions(emptyList()), path, silent).run() } }