Skip to content

Commit

Permalink
CLI: change output format with --print
Browse files Browse the repository at this point in the history
  • Loading branch information
nichtich committed Jun 7, 2024
1 parent ef43147 commit b978031
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,21 @@ The following options (each with default status) are supported to report:

Proper validation of schemas requires additional libraries [ajv] and [ajv-formats] to be installed.

The JSON format emitted with option `-p` or `--print` looks like this:

~~~json
{
"fields": [
{ "key": "tag1", "value": "..." },
{ "key": "tag2", "value": "..." }
],
"types": []
}
~~~

It can be converted to flat key-value structure by piping to
[jq](https://jqlang.github.io/jq/) command `jq '.fields|from_entries'`.

## API

### Validator
Expand Down
1 change: 1 addition & 0 deletions lib/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ export async function validateFiles(files, schema, validationOptions, opt) {
ok = false
})
if (print) {
record.fields = record.fields.map(({tag,value}) => ({key:tag,value}))
console.log(JSON.stringify(record))
}
})
Expand Down

0 comments on commit b978031

Please sign in to comment.