From de3ae2ecb5a7b065305cc58940ec3c34aa87e29f Mon Sep 17 00:00:00 2001 From: brbousnguar Date: Mon, 27 Jul 2026 14:27:07 +0200 Subject: [PATCH] Fix input syntax in CLI help example Fixes mulesoft/data-weave-cli#113 --- README.md | 2 +- .../src/main/java/org/mule/weave/cli/DWCLI.java | 2 +- .../mule/weave/dwnative/cli/DataWeaveCLITest.scala | 12 ++++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 018178c8..66ce1bdc 100644 --- a/README.md +++ b/README.md @@ -105,7 +105,7 @@ Commands: repl Starts the DW repl. Example: - dw run -i payload "output application/json --- payload + dw run -i payload= "output application/json --- payload filter (item) -> item.age > 17" Documentation reference: diff --git a/native-cli/src/main/java/org/mule/weave/cli/DWCLI.java b/native-cli/src/main/java/org/mule/weave/cli/DWCLI.java index ee3bd421..feb7efe0 100644 --- a/native-cli/src/main/java/org/mule/weave/cli/DWCLI.java +++ b/native-cli/src/main/java/org/mule/weave/cli/DWCLI.java @@ -57,7 +57,7 @@ public void run(String[] args, Console console) { "(____/\\_/\\_/(__)\\_/\\_/(_/\\_)(____)\\_/\\_/ \\__/ (____)", footer = "Example:\n" + "\n" + - " dw run -i payload \"output application/json --- payload\n" + + " dw run -i payload= \"output application/json --- payload\n" + "filter (item) -> item.age > 17\"\n" + "\n" + " Documentation reference:\n" + diff --git a/native-cli/src/test/scala/org/mule/weave/dwnative/cli/DataWeaveCLITest.scala b/native-cli/src/test/scala/org/mule/weave/dwnative/cli/DataWeaveCLITest.scala index 5671269d..26e5c58e 100644 --- a/native-cli/src/test/scala/org/mule/weave/dwnative/cli/DataWeaveCLITest.scala +++ b/native-cli/src/test/scala/org/mule/weave/dwnative/cli/DataWeaveCLITest.scala @@ -219,6 +219,18 @@ class DataWeaveCLITest extends AnyFreeSpec with Matchers { maybeError.isEmpty shouldBe false } + "should run with input file using name=path form" in { + val tmpFile = java.io.File.createTempFile("test-input", ".json") + tmpFile.deleteOnExit() + java.nio.file.Files.writeString(tmpFile.toPath, """{"greeting":"hello"}""") + val stream = new ByteArrayOutputStream() + val console = new TestConsole(System.in, stream) + val dwcli = createCommandLine(console) + val exitCode = dwcli.execute("run", "-i", s"payload=${tmpFile.getAbsolutePath}", "output application/json --- payload.greeting") + exitCode shouldBe 0 + Source.fromBytes(stream.toByteArray, "UTF-8").mkString.trim shouldBe "\"hello\"" + } + "should run using parameter" in { val stream = new ByteArrayOutputStream() val testConsole = new TestConsole(System.in, stream)