Git Product home page Git Product logo

data-weave-cli's Introduction

DataWeave CLI

DataWeave CLI is a command-line interface that allows querying, filtering, and mapping structured data from different data sources like JSON, XML, CSV, YML to other data formats. It also allows to easily create data in such formats, all through the DataWeave language. For example:

dw run 'output json --- { message: ["Hello", "world"] joinBy " "}'

The DataWeave language is in the process of being open-sourced. You can read our announcement here. Our journey has just begun and it will take some time for the code to be available. In the meantime, we want to start engaging with our community to understand how DataWeave could be used and integrated.

If you are interested on leveraging DataWeave:

  1. Join our community Slack
  2. Join the #opensource channel

For more news and all things DataWeave, visit our site

What is Included?

The binary distribution already ships with a set of modules and data formats that makes this useful for a very interesting and broad set of use cases.

Included Modules

Supported Data Formats

MIME Type ID Supported Formats
application/csv csv CSV Format
application/json json JSON Format
application/octet-stream binary Binary Format
application/xml xml XML Format
application/x-ndjson ndjson Newline Delimited JSON Format (ndjson)
application/x-www-form-urlencoded urlencoded URL Encoded Format
application/yaml yaml YAML Format
multipart/form-data multipart Multipart Format
text/plain text Text Plain Format
text/x-java-properties properties Text Java Properties

Installation

Homebrew (Mac)

brew tap mulesoft-labs/data-weave
brew install dw

Manual Installation

  1. Download the latest release version according to your OS.
  2. Unzip the file on your <user.home>/.dw
  3. Add <user.home>/.dw/bin to your PATH

Build and Install

To build the project, you need to run gradlew with the graalVM distribution based on Java 11. You can download it at https://github.com/graalvm/graalvm-ce-builds/releases Set:

export GRAALVM_HOME=`pwd`/.graalvm/graalvm-ce-java11-22.3.0/Contents/Home
export JAVA_HOME=`pwd`/.graalvm/graalvm-ce-java11-22.3.0/Contents/Home

Execute the gradle task nativeCompile

./gradlew native-cli:nativeCompile

It takes several minutes so good time to take and refill your mate.

Once it finishes you will find the dw binary in native-cli/build/native/nativeCompile/dw

How to Use It

If the directory containing the dw executable is in your PATH, you can run dw from anywhere.

If it is not, go to the bin directory referenced in the installation instructions and run dw from there.

The following example shows the DataWeave CLI documentation

dw help
  ____   __  ____  __   _  _  ____   __   _  _  ____
(    \ / _\(_  _)/ _\ / )( \(  __) / _\ / )( \(  __)
 ) D (/    \ )( /    \\ /\ / ) _) /    \\ \/ / ) _)
(____/\_/\_/(__)\_/\_/(_/\_)(____)\_/\_/ \__/ (____)
Usage: <main class> [-hV] [COMMAND]
  -h, --help      Show this help message and exit.
  -V, --version   Print version information and exit.
Commands:
  run            Runs provided DW script.
  wizard         Wizard actions.
    add            Adds a new Wizard to your network of trusted wizards.
  validate       Validate if a script is valid or not.
  migrate        Translates a DW1 script into a DW2 script.
  spell          Runs the specified Spell.
    create         Creates a new spell with the given name.
    list           List all available spells.
    update         Update all spells to the latest one.
  help           Display help information about the specified command.
  repl           Starts the DW repl.
Example:

 dw  run -i payload <fullPathToUser.json> "output application/json --- payload
filter (item) -> item.age > 17"

 Documentation reference:

 https://docs.mulesoft.com/dataweave/latest/

DataWeave CLI Environment Variables

The following are the DataWeave CLI environment variables that you can set in your operating system:

Environment Variable Description
DW_HOME The directory where the home will be found if not defined ~/.dw will be used.
DW_DEFAULT_INPUT_MIMETYPE The default mimeType that is going to be used for the standard input. If not defined application/json will be used.
DW_DEFAULT_OUTPUT_MIMETYPE The default output mimeType that is going to be if not defined. If not defined application/json will be used.

Dependency Manager

In order for a spell to depend on a library it can include a library it can use the dependencies.dwl to specify the list of dependencies that it should be included and download

%dw 2.0
var mavenRepositories = [{
    url: "https://maven.anypoint.mulesoft.com/api/v3/maven"
}]
---
{
  dependencies: [
    {
      kind: "maven",
      artifactId: "data-weave-analytics-library",
      groupId: "68ef9520-24e9-4cf2-b2f5-620025690913",
      version: "1.0.1",
      repositories: mavenRepositories // By default mulesoft, exchange and central are being added
    }
  ]
}

Querying Content From a File

Giving the following input file users.json

[
  {
    "name": "User1",
    "age": 19
  },
  {
    "name": "User2",
    "age": 18
  },
  {
    "name": "User3",
    "age": 15
  },
  {
    "name": "User4",
    "age": 13
  },
  {
    "name": "User5",
    "age": 16
  }
]

Let's query users old enough to drink alcohol:

dw run -i payload=<fullpathToUsers.json> "output application/json --- payload filter (item) -> item.age > 17"

Output

[
  {
    "name": "User1",
    "age": 19
  },
  {
    "name": "User2",
    "age": 18
  }
]

Query Content From Standard Input

cat <fullpathToUser.json> | dw run "output application/json --- payload filter (item) -> item.age > 17"

Redirecting the Output to a File

dw "output application/xml --- users: {( 1 to 100 map (item) -> {user: "User" ++ item} )}" >> out.xml

CURL + DataWeave => Power API Playground

An interesting use case for the DataWeave CLI is to combine it with curl

Query a GET Response

We can use the GitHub API to query commits of a repository.

We can easily get the first commit by doing:

curl "https://api.github.com/repos/mulesoft/mule/commits?per_page=5" | dw "payload[0]"

or we can get the message by doing:

curl "https://api.github.com/repos/mulesoft/mule/commits?per_page=5" | dw "{message: payload[0].commit.message}"

Generate a Request with Body

This example uses the jsonplaceholder API to update a resource.

Steps:

  1. Search the post resource with the id = 1.
  2. Use DataWeave CLI to create a JSON output changing the post title My new title.
  3. Finally, update the post resource.
curl https://jsonplaceholder.typicode.com/posts/1 | dw "output application/json --- { id: payload.id, title: 'My new title', body: payload.body, userId: payload.userId }" | curl -X PUT -H "Content-type: application/json; charset=UTF-8" -T "/dev/stdin" https://jsonplaceholder.typicode.com/posts/1 -v

Output

{
  "id": 1,
  "title": "My new title",
  "body": "quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto",
  "userId": 1
}

Using parameters

Using the internal map params, we can access injected parameters in the command line with the -p option

dw run -p myName=Julian "output json --- { name : params.myName }"

Output

{
  "name": "Julian"
}

Contributions Welcome

Contributions to this project can be made through Pull Requests and Issues on the GitHub Repository.

Before creating a pull request review the following:

When you submit your pull request, you are asked to sign a contributor license agreement (CLA) if we don't have one on file for you.

data-weave-cli's People

Contributors

afelisatti avatar andres-rad avatar balbifm avatar chrischolette-ms avatar jerneyio avatar leansh avatar machaval avatar manikmagar avatar mlischetti avatar svacas avatar svc-scm avatar tomodc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

data-weave-cli's Issues

The Playground not working!

Describe the bug
dw's version > 1.0.24
'dw --eval --spell Playground' is not working
The web server hangs.

Desktop (please complete the following information):

  • OS: linux
  • Browser [e.g. chrome]

--file help is incorrect

Describe the bug
-f,--file
Specifies output file for the
transformation if not standard
output will be used.

To Reproduce
Steps to reproduce the behavior:

  1. dw --help

Expected behavior
Specifies the
transformation file containing dataweave to be used.

Desktop (please complete the following information):

  • OS: iOS

`-path` default

-path should default to something like ~/.dw/libs so users don't need to enter this over and over if they're using Modules. DW should also look for a variable present like DW_LIB_PATH. Precedence would be as follows:

  1. Modules location set with dw -path
  2. Modules location set with DW_LIB_PATH
  3. Default module location

Add to Homebrew

Is your feature request related to a problem? Please describe.
Users shouldn't need to come to github, download a zip and move files around. Getting this on Homebrew would help Macintosh users. Not sure about other package manager or other platforms like Windows. This would also make pulling in updates to data-weave-native a lot less painful.

Describe the solution you'd like
brew install dw

Describe alternatives you've considered
The alternative might be a script in the root of the project that deals with the installation, but then it's just a lot of custom scripting that Homebrew would normally handle.

Set in/out mimetypes as input parameters, env vars

When a client is dealing with a single API, the input/output mimetypes are typically constant, but the CLI does not accomodate for this. The DW CLI seems to default to the following when it doesn't have enough information to determine mimetype:

$ dw input payload application/json output application/dw ...

So if your input/output is anything other that json/dw, you need to explicitly set it every time.

It would be nice to pass in what you'd like:

$ dw -input payload '/file' application/xml -output application/xml 'payload root

It would be also nice if you could use defaults as env vars as well:

$ echo $DW_DEFAULT_INPUT_MIMETYPE
application/xml
$ echo $DW_DEFAULT_OUTPUT_MIMETYPE
application/xml
$ curl ... | dw 'payload.root'` # will take in and output xml

Input parameters should override env vars, and env vars should override dw defaults.

--path takes too long to process when directory is large

Describe the bug
If the directory used by --path contains a large number of directories, dw takes too long to search them for DW files.

To Reproduce

The easiest way I know to replicate this is to add a .dwl file to ~/, and specify that as your path.

How does -path work?

It's not clear how to use the -path argument.

How do you build the jars it's looking for? What does it do when it finds the Jars (are the modules added so you can access them from within the DW script)? What would it do with a "weave file"? Does it need a special file extension?

The following does not work:

Contents of utils.dwl:

%dw 2.0

fun addUnderscore(s: String): String = s ++ "_"

Running script:

$ dw -path /Users/JoshuaErney/Desktop/utils.dwl 'output application/json --- { root: { hello: addUnderscore("world") } }'

[Error] Unable to resolve reference of addUnderscore.

1| output application/json --- { root: { hello: addUnderscore("world") } }
                                                ^^^^^^^^^^^^^

Releasing with JReleaser

Great CLI tool!

I wanted to see if JReleaser could be introduced to streamline and simplify the release process to publish artifacts, create GitHub releases, update brew taps, and more means of distributing the tool. I am happy to give it a try for this repo it looks good.

NPE when using `-path`

Describe the bug
NPE when using -path

To Reproduce
Steps to reproduce the behavior:

DIRECTORY=<pick your directory>

cd $DIRECTORY

echo '%dw 2.0
fun addUnderscore(s) = s ++ "_"
` > utils.dwl

dw -path $DIRECTORY 'output application/json import * from utils --- { hello: addUnderscore("world") }'

Here's the stack trace:

java.lang.NullPointerException
	at scala.collection.mutable.ArrayOps$ofRef$.length$extension(ArrayOps.scala:204)
	at scala.collection.mutable.ArrayOps$ofRef.length(ArrayOps.scala:204)
	at scala.collection.IndexedSeqOptimized.foreach(IndexedSeqOptimized.scala:35)
	at scala.collection.IndexedSeqOptimized.foreach$(IndexedSeqOptimized.scala:33)
	at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:198)
	at org.mule.weave.dwnative.PathBasedResourceResolver.recursiveListFiles(PathBasedResourceResolver.scala:64)
	at org.mule.weave.dwnative.PathBasedResourceResolver.$anonfun$recursiveListFiles$1(PathBasedResourceResolver.scala:68)
	at org.mule.weave.dwnative.PathBasedResourceResolver.$anonfun$recursiveListFiles$1$adapted(PathBasedResourceResolver.scala:64)
	at scala.collection.IndexedSeqOptimized.foreach(IndexedSeqOptimized.scala:36)
	at scala.collection.IndexedSeqOptimized.foreach$(IndexedSeqOptimized.scala:33)
	at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:198)
	at org.mule.weave.dwnative.PathBasedResourceResolver.recursiveListFiles(PathBasedResourceResolver.scala:64)
	at org.mule.weave.dwnative.PathBasedResourceResolver.$anonfun$recursiveListFiles$1(PathBasedResourceResolver.scala:68)
	at org.mule.weave.dwnative.PathBasedResourceResolver.$anonfun$recursiveListFiles$1$adapted(PathBasedResourceResolver.scala:64)
	at scala.collection.IndexedSeqOptimized.foreach(IndexedSeqOptimized.scala:36)
	at scala.collection.IndexedSeqOptimized.foreach$(IndexedSeqOptimized.scala:33)
	at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:198)
	at org.mule.weave.dwnative.PathBasedResourceResolver.recursiveListFiles(PathBasedResourceResolver.scala:64)
	at org.mule.weave.dwnative.PathBasedResourceResolver.$anonfun$loadResources$1(PathBasedResourceResolver.scala:45)
	at org.mule.weave.dwnative.PathBasedResourceResolver.$anonfun$loadResources$1$adapted(PathBasedResourceResolver.scala:22)
	at scala.collection.IndexedSeqOptimized.foreach(IndexedSeqOptimized.scala:36)
	at scala.collection.IndexedSeqOptimized.foreach$(IndexedSeqOptimized.scala:33)
	at scala.collection.mutable.WrappedArray.foreach(WrappedArray.scala:39)
	at org.mule.weave.dwnative.PathBasedResourceResolver.loadResources(PathBasedResourceResolver.scala:22)
	at org.mule.weave.dwnative.PathBasedResourceResolver.entries$lzycompute(PathBasedResourceResolver.scala:73)
	at org.mule.weave.dwnative.PathBasedResourceResolver.entries(PathBasedResourceResolver.scala:73)
	at org.mule.weave.dwnative.PathBasedResourceResolver.resolve(PathBasedResourceResolver.scala:76)
	at org.mule.weave.v2.parser.phase.ResourceBasedModuleParser.loadModule(ModuleLoader.scala:126)
	at org.mule.weave.v2.parser.phase.ModuleLoaderManager.$anonfun$loadModule$3(ModuleLoader.scala:80)
	at scala.collection.immutable.Stream.flatMap(Stream.scala:489)
	at org.mule.weave.v2.parser.phase.ModuleLoaderManager.$anonfun$loadModule$2(ModuleLoader.scala:79)
	at scala.Option.flatMap(Option.scala:188)
	at org.mule.weave.v2.parser.phase.ModuleLoaderManager.loadModule(ModuleLoader.scala:77)
	at org.mule.weave.v2.parser.phase.DefaultModuleParserManager.parseModule(ModuleParserManager.scala:94)
	at org.mule.weave.v2.parser.phase.CompositeModuleParserManager.$anonfun$parseModule$2(ModuleParserManager.scala:179)
	at scala.collection.immutable.Stream.flatMap(Stream.scala:493)
	at org.mule.weave.v2.parser.phase.CompositeModuleParserManager.parseModule(ModuleParserManager.scala:179)
	at org.mule.weave.v2.parser.phase.ParsingContext.tryToParseModule(ParsingContext.scala:98)
	at org.mule.weave.v2.parser.phase.ImportsValidation.$anonfun$checkImports$2(ImportsValidation.scala:16)
	at scala.collection.Iterator.foreach(Iterator.scala:941)
	at scala.collection.Iterator.foreach$(Iterator.scala:941)
	at scala.collection.AbstractIterator.foreach(Iterator.scala:1429)
	at scala.collection.IterableLike.foreach(IterableLike.scala:74)
	at scala.collection.IterableLike.foreach$(IterableLike.scala:73)
	at scala.collection.AbstractIterable.foreach(Iterable.scala:56)
	at org.mule.weave.v2.parser.phase.ImportsValidation.checkImports(ImportsValidation.scala:13)
	at org.mule.weave.v2.parser.phase.ImportsValidation.transform(ImportsValidation.scala:31)
	at org.mule.weave.v2.parser.phase.AstNodeTransformationPhase.$anonfun$doTransform$1(AstNodeTransformationPhase.scala:8)
	at org.mule.weave.v2.parser.phase.AstNodeTransformationPhase.$anonfun$doTransform$1$adapted(AstNodeTransformationPhase.scala:8)
	at scala.collection.immutable.List.foreach(List.scala:392)
	at org.mule.weave.v2.parser.phase.AstNodeTransformationPhase.doTransform(AstNodeTransformationPhase.scala:8)
	at org.mule.weave.v2.parser.phase.AstNodeTransformationPhase.traverse(AstNodeTransformationPhase.scala:12)
	at org.mule.weave.v2.parser.phase.AstNodeTransformationPhase.call(AstNodeTransformationPhase.scala:17)
	at org.mule.weave.v2.parser.phase.AstNodeTransformationPhase.call(AstNodeTransformationPhase.scala:5)
	at org.mule.weave.v2.parser.phase.CompositeCompilationPhase.call(CompilationPhase.scala:31)
	at org.mule.weave.v2.parser.phase.CompositeCompilationPhase.call(CompilationPhase.scala:27)
	at org.mule.weave.v2.parser.phase.CompositeCompilationPhase.call(CompilationPhase.scala:27)
	at org.mule.weave.v2.parser.phase.CompositeCompilationPhase.call(CompilationPhase.scala:31)
	at org.mule.weave.v2.parser.phase.CompositeCompilationPhase.call(CompilationPhase.scala:27)
	at org.mule.weave.v2.parser.phase.CompositeCompilationPhase.call(CompilationPhase.scala:27)
	at org.mule.weave.v2.parser.MappingParser$.parse(MappingParser.scala:71)
	at org.mule.weave.dwnative.NativeRuntime.run(NativeRuntime.scala:71)
	at org.mule.weave.dwnative.cli.DataWeaveCLIRunner.run(DataWeaveCLI.scala:169)
	at org.mule.weave.dwnative.cli.DataWeaveCLIRunner.run(DataWeaveCLI.scala:39)
	at org.mule.weave.dwnative.cli.DataWeaveCLI$.delayedEndpoint$org$mule$weave$dwnative$cli$DataWeaveCLI$1(DataWeaveCLI.scala:23)
	at org.mule.weave.dwnative.cli.DataWeaveCLI$delayedInit$body.apply(DataWeaveCLI.scala:20)
	at scala.Function0.apply$mcV$sp(Function0.scala:39)
	at scala.Function0.apply$mcV$sp$(Function0.scala:39)
	at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:17)
	at scala.App.$anonfun$main$1$adapted(App.scala:80)
	at scala.collection.immutable.List.foreach(List.scala:392)
	at scala.App.main(App.scala:80)
	at scala.App.main$(App.scala:78)
	at org.mule.weave.dwnative.cli.DataWeaveCLI$.main(DataWeaveCLI.scala:20)
	at org.mule.weave.dwnative.cli.DataWeaveCLI.main(DataWeaveCLI.scala)

Expected behavior
I would expect this to output { "hello": "world_" }

Desktop (please complete the following information):

  • OS: Mac OS

Additional context
Add any other context about the problem here.

Can not use script that uses dw::util::Values::update function

To Reproduce

  • Execute the following one-liner:
$ echo '{ "name" : "Mariano" }' | dw '%dw 2.0 output application/json --- payload dw::util::Values::update "name" with "Gustavo"'

Expected behavior

{
    "name" : "Gustavo"
}

Actual Result

  • The following output
Error while executing the script:
Invalid input '}', expected schema, &, |, ',' or '|' (line 38, column 1):


38| }
    ^
Location:
dw::util::Tree (line: 38, column:1)

Environment

Java version: 1.8.0_202, vendor: Oracle Corporation
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.14.6", arch: "x86_64", family: "mac"

Master branch fails to compile the CLI

Unable to compile latest build from master -

GraalVM is used:

❯ jdk -version
openjdk version "11.0.17" 2022-10-18
OpenJDK Runtime Environment GraalVM CE 22.3.0 (build 11.0.17+8-jvmci-22.3-b08)
OpenJDK 64-Bit Server VM GraalVM CE 22.3.0 (build 11.0.17+8-jvmci-22.3-b08, mixed mode)

Compiling native CLI:

❯ ./gradlew native-cli:nativeCompile
Starting a Gradle Daemon, 1 incompatible Daemon could not be reused, use --status for details

> Configure project :native-cli
Generating Versions File.

> Task :native-cli:compileScala
[Error] ~/codebase/data-weave-cli/native-cli/src/main/scala/org/mule/weave/dwnative/NativeRuntime.scala:67:5: overloaded method constructor DataWeaveScriptingEngine with alternatives:
  (componentsFactory: org.mule.weave.v2.runtime.ModuleComponentsFactory,parsingConfiguration: org.mule.weave.v2.runtime.ParserConfiguration)org.mule.weave.v2.runtime.DataWeaveScriptingEngine <and>
  ()org.mule.weave.v2.runtime.DataWeaveScriptingEngine <and>
  (componentsFactory: org.mule.weave.v2.runtime.ModuleComponentsFactory,parsingConfiguration: org.mule.weave.v2.runtime.ParserConfiguration,configuration: java.util.Properties)org.mule.weave.v2.runtime.DataWeaveScriptingEngine
 cannot be applied to (org.mule.weave.dwnative.NativeModuleComponentFactory, org.mule.weave.v2.runtime.ParserConfiguration, java.util.Properties, languageLevelService: org.mule.weave.v2.model.service.LanguageLevelService)
one error found

> Task :native-cli:compileScala FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':native-cli:compileScala'.
> Compilation failed

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 7s
1 actionable task: 1 executed

dw can't parse comment of xml

Describe the bug
dw can't parse comment of xml

To Reproduce

  1. I create a xml named a.xml
<a>
   <!-- aa -->
   <b>test</b>
</a>
  1. I use dw convert a.xml to json
dw -i payload a.xml "output application/json --- payload"
  1. I got this error message
�[31mError while executing the script:�[0m
�[31mscala.MatchError - 5 (of class java.lang.Integer)
scala.MatchError: 5 (of class java.lang.Integer)
       at org.mule.weave.v2.module.xml.reader.InMemoryXmlParserHelper$.parseStreamingNonNullValue(InMemoryXmlParserHelper.scala:148)
       at org.mule.weave.v2.module.xml.reader.InMemoryXmlParserHelper$.parseLazyValue(InMemoryXmlParserHelper.scala:138)
       at org.mule.weave.v2.module.xml.reader.InMemoryXmlParserHelper$.$anonfun$parseStreamingNonNullValue$2(InMemoryXmlParserHelper.scala:161)
       at org.mule.weave.v2.model.values.wrappers.LazyValue.value(DelegateValue.scala:79)
       at org.mule.weave.v2.model.values.wrappers.DelegateValue.evaluate(DelegateValue.scala:22)
       at org.mule.weave.v2.model.values.wrappers.DelegateValue.evaluate$(DelegateValue.scala:22)
       at org.mule.weave.v2.model.values.wrappers.LazyValue.evaluate(DelegateValue.scala:73)
       at org.mule.weave.v2.module.json.writer.JsonWriter.doWriteValue(JsonWriter.scala:154)
       at org.mule.weave.v2.module.writer.WriterWithAttributes.internalWriteValue(WriterWithAttributes.scala:35)
       at org.mule.weave.v2.module.writer.WriterWithAttributes.internalWriteValue$(WriterWithAttributes.scala:34)
       at org.mule.weave.v2.module.json.writer.JsonWriter.internalWriteValue(JsonWriter.scala:28)
       at org.mule.weave.v2.module.writer.WriterWithAttributes.writeAttributesAndValue(WriterWithAttributes.scala:30)
       at org.mule.weave.v2.module.writer.WriterWithAttributes.writeAttributesAndValue$(WriterWithAttributes.scala:15)
       at org.mule.weave.v2.module.json.writer.JsonWriter.writeAttributesAndValue(JsonWriter.scala:28)
       at org.mule.weave.v2.module.json.writer.JsonWriter.writeObject(JsonWriter.scala:94)
       at org.mule.weave.v2.module.json.writer.JsonWriter.doWriteValue(JsonWriter.scala:155)
       at org.mule.weave.v2.module.writer.Writer.writeValue(Writer.scala:41)
       at org.mule.weave.v2.module.writer.Writer.writeValue$(Writer.scala:39)
       at org.mule.weave.v2.module.json.writer.JsonWriter.writeValue(JsonWriter.scala:28)
       at org.mule.weave.v2.module.writer.DeferredWriter.doWriteValue(DeferredWriter.scala:73)
       at org.mule.weave.v2.module.writer.Writer.writeValue(Writer.scala:41)
       at org.mule.weave.v2.module.writer.Writer.writeValue$(Writer.scala:39)
       at org.mule.weave.v2.module.writer.DeferredWriter.writeValue(DeferredWriter.scala:16)
       at org.mule.weave.v2.module.writer.WriterHelper$.writeValue(Writer.scala:120)
       at org.mule.weave.v2.module.writer.WriterHelper$.writeAndGetResult(Writer.scala:98)
       at org.mule.weave.v2.interpreted.InterpretedMappingExecutableWeave.writeWith(InterpreterMappingCompilerPhase.scala:235)
       at org.mule.weave.v2.runtime.DataWeaveScript.doWrite(DataWeaveScriptingEngine.scala:459)
       at org.mule.weave.v2.runtime.DataWeaveScript.write(DataWeaveScriptingEngine.scala:416)
       at org.mule.weave.dwnative.NativeRuntime.run(NativeRuntime.scala:124)
       at org.mule.weave.dwnative.cli.DataWeaveCLIRunner.run(DataWeaveCLI.scala:370)
       at org.mule.weave.dwnative.cli.DataWeaveCLIRunner.run(DataWeaveCLI.scala:58)
       at org.mule.weave.dwnative.cli.DataWeaveCLI$.delayedEndpoint$org$mule$weave$dwnative$cli$DataWeaveCLI$1(DataWeaveCLI.scala:33)
       at org.mule.weave.dwnative.cli.DataWeaveCLI$delayedInit$body.apply(DataWeaveCLI.scala:29)
       at scala.Function0.apply$mcV$sp(Function0.scala:39)
       at scala.Function0.apply$mcV$sp$(Function0.scala:39)
       at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:17)
       at scala.App.$anonfun$main$1$adapted(App.scala:80)
       at scala.collection.immutable.List.foreach(List.scala:392)
       at scala.App.main(App.scala:80)
       at scala.App.main$(App.scala:78)
       at org.mule.weave.dwnative.cli.DataWeaveCLI$.main(DataWeaveCLI.scala:29)
       at org.mule.weave.dwnative.cli.DataWeaveCLI.main(DataWeaveCLI.scala), while writing Json at payload. at:
payload�[0m
  1. remove comment in xml ,its working.

dw should get the AppData/LocalAppData folder locations on Windows without crashing due to a PowerShell $Profile script

Describe the bug
To get the ApplicationData and LocalApplicationData user folders on Windows, a complex PowerShell command line is used, but can be broken if the user's PowerShell profile script has unexpected output.

To Reproduce
Steps to reproduce the behavior:

  1. Add the following to your PowerShell $Profile script:
Write-Host "?`n?"
  1. Run dw "output application/json --- true"
  2. Get a stack trace of java.nio.file.InvalidPathException: Illegal char <?> at index 0

Expected behavior
The AppData and LocalAppData folders are available as simple environment variables (APPDATA and LOCALAPPDATA, respectively), or you can use the simple PowerShell expressions [Environment]::GetFolderPath('ApplicationData') and [Environment]::GetFolderPath('LocalApplicationData') without compiling C# code via Add-Type to get at the low-level Windows API. But if you use PowerShell, be sure to include the -NoProfile and -NonInteractive parameters for the powershell.exe, otherwise the user profile script is implicitly executed before your -Command parameter, which can have unexpected results, and can even block execution.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Windows 10 version 20H2
  • Windows PowerShell 5.1.19041.546
  • DataWeave Command Line : V1.0.9
  • DataWeave Runtime: V2.3.2-SNAPSHOT

The "DataWeave: Create New Library Project" wizard of the DataWeave 2 VS Code Extension does not appear to be working anymore for the latest release of VS Code (1.79.0) on Windows 10

The "DataWeave: Create New Library Project" wizard of the DataWeave 2 VS Code Extension does not appear to be working anymore for the latest release of VS Code (1.79.0) on Windows 10.

To Reproduce
Steps to reproduce the behavior:

  1. In VS Code, select from the menu bar: View -> Command Palette...
  2. At the text prompt, type "DataWeave: " and select "DataWeave: Create New Library Project"
  3. Paste values from you clipboard into each of the five text prompts that follow
  4. Observe that nothing happens after completion of the fifth and final prompt.

Expected behavior
According to the online instructions for the DataWeave 2.0 Extension for VS Code, after completing the five text prompts of the wizard, a Yes/No prompt to open the new project in a new Visual Studio Code window should appear.

Screenshots
Menu 1
Menu 2
WizardStep5

Desktop (please complete the following information):

  • OS: Windows 10 Enterprise 22H2 (19045.2965)
  • Browser: Microsoft Edge (Version 114.0.1823.43 (Official build) (64-bit))
  • VS Code: 1.79.0

Additional context
In addition to nothing happening (after the final step five of the "DataWeave: Create New Library Project" wizard), it was frustrating while entering data into the text prompts. Switching the window focus from the wizard's text prompt to a text editor (for the purpose of copying some text into the clipboard to paste into the current text prompt) would cause the wizard to advance to the next text prompt before giving a chance to paste the desired text value for that particular text prompt (e.g. organization ID) from the clipboard.

Unable to hit https over command line

$ dw "%dw 2.0 output application/json --- readUrl(\"https://www.google.com\",\"application/xml\")"

Exception in thread "main" com.oracle.svm.core.jdk.UnsupportedFeatureError: Accessing an URL protocol that was not enabled. The URL protocol https is supported but not enabled by default. It must be enabled by adding the --enable-url-protocols=https option to the native-image command.
	at com.oracle.svm.core.util.VMError.unsupportedFeature(VMError.java:102)
	at com.oracle.svm.core.jdk.JavaNetSubstitutions.unsupported(JavaNetSubstitutions.java:201)
	at com.oracle.svm.core.jdk.JavaNetSubstitutions.getURLStreamHandler(JavaNetSubstitutions.java:162)
	at java.net.URL.getURLStreamHandler(URL.java:64)
	at java.net.URL.<init>(URL.java:599)
	at java.net.URL.<init>(URL.java:490)
	at java.net.URL.<init>(URL.java:439)
	at org.mule.weave.v2.runtime.core.functions.UrlProtocolHandler.createSourceProvider(ReadFunctionProtocolHandler.scala:44)
	at org.mule.weave.v2.runtime.core.functions.ReadUrlFunctionValue.createSourceProvider(ReadUrlFunctionValue.scala:35)
	at org.mule.weave.v2.runtime.core.functions.ReadFunctionValue.doExecute(ReadFunctionValue.scala:52)
	at org.mule.weave.v2.core.functions.BaseTernaryFunctionValue.call(TernaryFunctionValue.scala:32)
	at org.mule.weave.v2.core.functions.BaseTernaryFunctionValue.call$(TernaryFunctionValue.scala:31)
	at org.mule.weave.v2.runtime.core.functions.ReadFunctionValue.call(ReadFunctionValue.scala:27)
	at org.mule.weave.v2.interpreted.node.FunctionCallNode.doExecute(FunctionCallNode.scala:63)
	at org.mule.weave.v2.interpreted.node.ValueNode.execute(ValueNode.scala:25)
	at org.mule.weave.v2.interpreted.node.ValueNode.execute$(ValueNode.scala:20)
	at org.mule.weave.v2.interpreted.node.FunctionCallNode.execute(FunctionCallNode.scala:18)
	at org.mule.weave.v2.interpreted.node.structure.DocumentNode.doExecute(DocumentNode.scala:22)
	at org.mule.weave.v2.interpreted.node.ValueNode.execute(ValueNode.scala:25)
	at org.mule.weave.v2.interpreted.node.ValueNode.execute$(ValueNode.scala:20)
	at org.mule.weave.v2.interpreted.node.structure.DocumentNode.execute(DocumentNode.scala:10)
	at org.mule.weave.v2.interpreted.InterpretedMappingExecutableWeave.$anonfun$write$4(InterpreterMappingCompilerPhase.scala:239)
	at org.mule.weave.v2.module.writer.WriterHelper$.writeValue(Writer.scala:110)
	at org.mule.weave.v2.module.writer.WriterHelper$.writeAndGetResult(Writer.scala:88)
	at org.mule.weave.v2.interpreted.InterpretedMappingExecutableWeave.write(InterpreterMappingCompilerPhase.scala:239)
	at org.mule.weave.dwnative.NativeRuntime.run(NativeRuntime.scala:108)
	at org.mule.weave.dwnative.cli.DataWeaveCLIRunner.run(DataWeaveCLI.scala:169)
	at org.mule.weave.dwnative.cli.DataWeaveCLIRunner.run(DataWeaveCLI.scala:39)
	at org.mule.weave.dwnative.cli.DataWeaveCLI$.delayedEndpoint$org$mule$weave$dwnative$cli$DataWeaveCLI$1(DataWeaveCLI.scala:23)
	at org.mule.weave.dwnative.cli.DataWeaveCLI$delayedInit$body.apply(DataWeaveCLI.scala:20)
	at scala.Function0.apply$mcV$sp(Function0.scala:39)
	at scala.Function0.apply$mcV$sp$(Function0.scala:39)
	at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:17)
	at scala.App.$anonfun$main$1$adapted(App.scala:80)
	at scala.collection.immutable.List.foreach(List.scala:392)
	at scala.App.main(App.scala:80)
	at scala.App.main$(App.scala:78)
	at org.mule.weave.dwnative.cli.DataWeaveCLI$.main(DataWeaveCLI.scala:20)
	at org.mule.weave.dwnative.cli.DataWeaveCLI.main(DataWeaveCLI.scala)

How to get it working on command line ?

NDJSON format not recognized

Describe the bug
Format NDJSON is not recognized.

To Reproduce

  1. Installed with brew.
  2. Execute a transformation with input payload format application/x-ndjson
$ dw run -i payload=in.ndjson "%dw 2.0  output application/json  input payload  application/x-ndjson  --- payload"
[ERROR] Error while executing the script:
[ERROR] Unknown content type `application/x-ndjson`. Supported content types are: `application/dw`, `application/csv`, `application/json`, `multipart/form-data`, `application/octet-stream`, `text/x-java-properties`, `text/plain`, `application/x-www-form-urlencoded`, `application/xml`, `application/yaml`

1| %dw 2.0  output application/json  input payload  application/x-ndjson  --- payload
                                                    ^^^^^^^^^^^^^^^^^^^^
Trace:
  at anonymous::main (line: 1, column: 50) at:

1| %dw 2.0  output application/json  input payload  application/x-ndjson  --- payload
                                                    ^^^^^^^^^^^^^^^^^^^^

Expected behavior
The readme file indicates that the format is supported,.

Screenshots
N/A

Desktop (please complete the following information):

  • OS: macOS 13.3.1. Also happens in Windows.
dw --version
Command Line : V1.0.34
Runtime : V2.6.0-SNAPSHOT

Additional context
Issue originally mentioned in Stackoverflow question: https://stackoverflow.com/questions/76292778/dataweave-in-windows-to-process-ndjson-files-x-ndjson-does-not-work

Re-add the --path parameter

Is your feature request related to a problem? Please describe.
In previous verions of data-weave-cli (at least in 1.0.19) it was possible to add a folder with --path, where the cli searches for scripts. This was a very useful feature.

Describe the solution you'd like
Re-add the --path parameter.

Describe alternatives you've considered
Alternatively allow more than one file for the -f / --file parameter

Additional context
The --path functionality was removed with this PR: #27
Why?

Can't build because RunWeaveCommand.scala:98:18

Describe the bug

Can't compile project due to an error RunWeaveCommand.scala:98:18: overloaded method value apply with alternatives

To Reproduce

You can choose one of images: ubuntu:22.04 or ubuntu:22.10

docker run -it --rm ubuntu:22.04

or

docker run -it --rm ubuntu:22.10

And run commands in container:

cd ~
apt update
apt install -y git curl
git clone https://github.com/mulesoft-labs/data-weave-cli.git
cd data-weave-cli/
git checkout v1.0.25
./install-graalvm.sh
GRAALVM_HOME=${PWD}/.graalvm/graalvm-ce-java11-22.2.0/ JAVA_HOME=${PWD}/.graalvm/graalvm-ce-java11-22.2.0/ ./gradlew native-cli:nativeCompile
Compile logs
root@a5cf12e88a3d:~/data-weave-cli# GRAALVM_HOME=${PWD}/.graalvm/graalvm-ce-java11-22.2.0/ JAVA_HOME=${PWD}/.graalvm/graalvm-ce-java11-22.2.0/ ./gradlew native-cli:nativeCompile

> Configure project :native-cli
Generating Versions File.

> Task :native-cli:compileScala
[Error] /root/data-weave-cli/native-cli/src/main/scala/org/mule/weave/dwnative/cli/commands/RunWeaveCommand.scala:98:18: overloaded method value apply with alternatives:
(value: org.mule.weave.v2.model.structure.ObjectSeq)org.mule.weave.v2.model.values.ObjectValue <and>
(value: Array[org.mule.weave.v2.model.structure.KeyValuePair])org.mule.weave.v2.model.values.ObjectValue
cannot be applied to (scala.collection.immutable.IndexedSeq[org.mule.weave.v2.model.structure.KeyValuePair])
one error found

> Task :native-cli:compileScala FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':native-cli:compileScala'.
> Compilation failed

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 6s
2 actionable tasks: 1 executed, 1 up-to-date

Expected behavior

Builded project

Desktop

host

lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 22.04.1 LTS
Release:	22.04
Codename:	jammy

===

docker --version
Docker version 20.10.12, build 20.10.12-0ubuntu4

docker containers

docker pull ubuntu:22.04
22.04: Pulling from library/ubuntu
Digest: sha256:4b1d0c4a2d2aaf63b37111f34eb9fa89fa1bf53dd6e4ca954d47caebca4005c2
Status: Image is up to date for ubuntu:22.04
docker.io/library/ubuntu:22.04

===

docker pull ubuntu:22.10
22.10: Pulling from library/ubuntu
Digest: sha256:edc5125bd9443ab5d5c92096cf0e481f5e8cb12db9f5461ab1ab7a936c7f7d30
Status: Image is up to date for ubuntu:22.10
docker.io/library/ubuntu:22.10

Documentation Improvements

  • Add example for -path
  • Remove > <command> pattern as it prevents users from copy-pasting multi-line scripts into their shell
  • Fix some typos

Outdated message when spells are older than 30 days

Describe the bug
Outdated warning message when the spells are old.

To Reproduce
Steps to reproduce the behavior:

  1. Modify the access/modified timestamp of the file $DW_HOME/grimoires/lastUpdate.txt to be older than 30 days. Eg:
    touch -d '2023-09-01T00:00:00' ~/.dw/grimoires/lastUpdate.txt
  2. Run any spell. Eg:
    dw spell --eval Playground
  3. A warning legend will appear indicating to update the spells by running dw update-spells, which it's oudated

Expected behavior
The legend shown when not updating the spells for more than 30 days should show the correct command to update the grimoires: dw spell update

Screenshots
image

Desktop (please complete the following information):

  • OS: macOS Ventura
  • Version 13.6 (22G120)
  • DW-CLI version: (Command Line : V1.0.34 / Runtime : V2.6.0-SNAPSHOT)

Release download (windows and others?) missing .zip extension

Describe the bug
The manual downloads have downloaded files with no extension. e.g. on windows that come out as dw-X.Y.Z-Windows - should have a .zip at the end.

To Reproduce
Go to the downloads for releases: https://github.com/mulesoft-labs/data-weave-cli/releases
Download the windows one, it'll save as dw-1.0.24-Windows
The source files however have their extensions when downloaded, so they are ok.

Expected behavior
Should have a .zip at the end so people can fire up the unzip tool/know what the format is of the file (on linux/mac it might be ambiguous what the file is, whether it should be executed as is.. on windows people might think they need to add a .exe or something).

Desktop:

  • OS: windows 11
  • Browser: chrome
  • Version: 105.0.5195.127 (Official Build) (64-bit)

Linux Support?

Describe the bug
Get no output on Linux to stdout or specified output file.

To Reproduce
Steps to reproduce the behavior:
Download Binary. Extract to $HOME/.dw. Attempt to run any of the examples from the README.

Expected behavior
Output.

Attempted to execute on Fedora 31 and Ubuntu 18.04.

Environment variables accessible

Is your feature request related to a problem? Please describe.
I was wondering if this CLI / Native version supports accessing environment variables and the like. In the embedded Mule version, we see the ability to query the local context using the p() function.
Is this supported in the CLI for environment variables?

Describe the solution you'd like
I would like to be able to inject a variable map with an arbitrary name. This would be accessible using a pre-defined keyword vars in the script. If I need to set a variable based on say, the current hostname + kernel version of the server, I could run something like

$ export chost=`(uname -sra)`
$ dw -i payload state.json -v 'host: "$chost" ' "output application/json --- payload mergeWith vars.host"

I am reminded of how cURL does headers for HTTP calls. Adding this style of params/vars would be very helpful in making scripts more flexible on the server-side instead of having to stringbash the resulting JSON with sed.
cURL uses -H, perhaps dw could use -V or -v
Describe alternatives you've considered
Not using dataweave native

`--main` invalid argument and throws AIOB exception

Describe the bug

Trying to run a mapping file from jar -

❯ dw --path ~/dev/sample.jar  --main "Test.dwl"
[ERROR] Parameters configuration error:
[ERROR] Invalid argument --main

Looks like code has it -main instead of --main, see here.

When using -main, it results in this error -

❯ dw --path ~/dev/sample.jar  -main "Test.dwl"
[ERROR] Unexpected exception happened while executing command. Please report this as an issue in https://github.com/mulesoft-labs/data-weave-cli/issues with all the details to reproduce.
Stacktrace is: java.lang.ArrayIndexOutOfBoundsException: Index 4 out of bounds for length 4
	at org.mule.weave.dwnative.cli.CLIArgumentsParser.$anonfun$parse$3(CLIArgumentsParser.scala:226)
	at org.mule.weave.dwnative.cli.commands.RunWeaveCommand.doRun(RunWeaveCommand.scala:89)
	at org.mule.weave.dwnative.cli.commands.RunWeaveCommand.exec(RunWeaveCommand.scala:56)
	at org.mule.weave.dwnative.cli.DataWeaveCLIRunner.run(DataWeaveCLI.scala:30)
	at org.mule.weave.dwnative.cli.DataWeaveCLI$.delayedEndpoint$org$mule$weave$dwnative$cli$DataWeaveCLI$1(DataWeaveCLI.scala:11)
	at org.mule.weave.dwnative.cli.DataWeaveCLI$delayedInit$body.apply(DataWeaveCLI.scala:9)
	at scala.Function0.apply$mcV$sp(Function0.scala:39)
	at scala.Function0.apply$mcV$sp$(Function0.scala:39)
	at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:17)
	at scala.App.$anonfun$main$1$adapted(App.scala:80)
	at scala.collection.immutable.List.foreach(List.scala:392)
	at scala.App.main(App.scala:80)
	at scala.App.main$(App.scala:78)
	at org.mule.weave.dwnative.cli.DataWeaveCLI$.main(DataWeaveCLI.scala:9)
	at org.mule.weave.dwnative.cli.DataWeaveCLI.main(DataWeaveCLI.scala)

It can be reproduced by simply running dw -main "Test.dwl".

substring fails depending on whether we log the contents of a variable (works) or not (does not work)

Describe the bug
It looks like the var fileName (see script below) is like a “promise” ? so when we force it to be logged (line 8 , it gets instantiated and therefore the substring works, but when we don’t enable the log line, then the substring finds the “promise” and it fails? Forgive me if my usage of “promise” is not adequate here, but I meant to say that the instantiation of the variable hasn’t really happened when the substring takes action?

To Reproduce

This is the script:

import substring from dw::core::Strings

output text/plain

fun getFileName(instance: Object) : String = do {
    
    var fileName = (("./filePrefix_") ++ (instance.id as String) ++ (".json") ) as String
    //var dummy = log(fileName)
    var fileURI = ("file://" ++ substring(fileName,1,sizeOf(fileName))) as String
    ---
    fileURI
}

---
getFileName({id:912345})

if you run the previous code, you get an exception:

[ERROR] Error while executing the script:
[ERROR] Internal error : java.lang.StringIndexOutOfBoundsException : begin 0, end -2, length 5
java.lang.StringIndexOutOfBoundsException: begin 0, end -2, length 5
        at [email protected]/java.lang.String.checkBoundsBeginEnd(String.java:3319)
        at [email protected]/java.lang.String.substring(String.java:1874)
        at [email protected]/java.lang.String.subSequence(String.java:1913)
        at org.mule.weave.v2.model.structure.SliceCharSequence.subSequence(SliceCharSequence.scala:90)
        at org.mule.weave.v2.runtime.core.operator.selectors.StringRangeSelectorOperator.doExecute(RangeSelectorOperator.scala:118)
        at org.mule.weave.v2.core.functions.BaseBinaryFunctionValue.call(BinaryFunctionValue.scala:40)
        at org.mule.weave.v2.core.functions.BaseBinaryFunctionValue.call$(BinaryFunctionValue.scala:39)

But if you uncomment the line 8 ( //var dummy = log(fileName))

import substring from dw::core::Strings

output text/plain

fun getFileName(instance: Object) : String = do {
    
    var fileName = (("./filePrefix_") ++ (instance.id as String) ++ (".json") ) as String
    var dummy = log(fileName)
    var fileURI = ("file://" ++ substring(fileName,1,sizeOf(fileName))) as String
    ---
    fileURI
}

---
getFileName({id:912345})

The script runs without problems showing the log entry:

dw -f dw/testIssue.dwl
"./filePrefix_912345.json"
file:///filePrefix_912345.json

This behaviour has started to happen after upgrading to CLI version V1.0.28. My previous version was V1.0.25 and it didn't happen.

Expected behavior
The substring function should work regardless of whether we log the content of the variable or not

Desktop (please complete the following information):

  • OS: iOS. (CLI installed via brew)
  • Version of CLI: V1.0.28

Unable to resolve reference to payload error

Describe the bug
Running second example in README.md produces the error:

[Error] Unable to resolve reference of payload.

To Reproduce
Steps to reproduce the behavior: Run second example in README.md

> cat users.json | dw "output application/json --- payload filter (item) -> item.age > 17"

Expected behavior

The same result as the first example.

Desktop (please complete the following information):

  • OS: Arch Linux

Other info

Thank you for creating this. I'm new to this space and was thankful when I came across it. I do have other questions about the application. First, when I run the first example it runs successfully but it also outputs the following messages:

Unable to load descriptor META-INF/dw-extensions.dwl reasons:
Unable to resolve module with identifier dw::Core.
Unknown location

Next, the third example uses double quotes within the script which causes an error. They need to be escaped or single quotes used.

Finally, it would be helpful to see an example using the -main argument. I'm not sure how it is to be used.

Windows version

Is there a windows version of dataweave cli ? If not can it be added ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.