Skip to content

Commit

Permalink
feat: Add gb64json format for input and output
Browse files Browse the repository at this point in the history
  • Loading branch information
nmaguiar committed May 18, 2024
1 parent 370d560 commit 0ca5593
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/docs/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ List of data input types that can be auto-detected (through the file extension o
| ch | An OpenAF channel format |
| csv | A CSV format (auto-detected) |
| db | A JDBC query to a database |
| gb64json | Equivalent to in=base64 and base64gzip=true |
| hsperf | A Java hsperfdata* file (requires file=hsperfdata_user/123) |
| ini | INI/Properties format |
| json | A JSON format (auto-detected) |
Expand Down Expand Up @@ -137,6 +138,7 @@ List of available formats to use with the _output_ option:
| ctree | A tree-like forcely colored format |
| db | Output to a JDBC database |
| envs | Tries to output the input data as OS environment variables setting commands |
| gb64json | Equivalent to out=base64 and base64gzip=true |
| grid | A multiple output ascii grid (usefull together with 'loop') |
| html | An HTML format |
| ini | A INI/Properties format (arrays are not supported) |
Expand Down
6 changes: 6 additions & 0 deletions src/include/inputFns.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,12 @@ var _inputFns = new Map([
}
_$o(_r, options)
}],
["gb64json", (_res, options) => {
var _r
_showTmpMsg()
_r = af.fromBytes2String(io.gunzip(af.fromBase64(_res, true)))
_$o(_r, options)
}],
["oafp", (_res, options) => {
params.__inception = true
var _r = _fromJSSLON(_res)
Expand Down
9 changes: 9 additions & 0 deletions src/include/outputFns.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,15 @@ var _outputFns = new Map([
_print(af.fromBytes2String(af.toBase64Bytes(_o)))
}
}],
["gb64json", (r, options) => {
var _o = ""
if (isString(r))
_o = r
else
_o = stringify(r)

_print(af.fromBytes2String(af.toBase64Bytes(io.gzip(af.fromString2Bytes(_o)))))
}],
["grid" , (r, options) => {
if (isUnDef(params.grid)) _exit(-1, "For out=grid you need to provide a grid=...")
let _f = _fromJSSLON(_$(params.grid, "grid").isString().$_())
Expand Down

0 comments on commit 0ca5593

Please sign in to comment.