Skip to content

Commit

Permalink
feat: Add support for oaf input format and improvements on chart output
Browse files Browse the repository at this point in the history
  • Loading branch information
nmaguiar committed Jun 22, 2024
1 parent 8f9e162 commit ce4fca5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/docs/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ List of data input types that can be auto-detected (through the file extension o
| md | A Markdown format |
| mdtable | A Markdown table format |
| ndjson | A NDJSON format |
| oaf | Takes an OpenAF scripting code to execute and use the result as input |
| oafp | Takes a JSON/SLON map input as parameters for calling a sub oafp process (arrays will call multiple oafp processes) |
| openmetrics | An OpenMetrics/Prometheus compatible format |
| raw | Passes the input directly to transforms and output |
Expand Down
6 changes: 6 additions & 0 deletions src/include/inputFns.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,12 @@ var _inputFns = new Map([
_r = af.fromBytes2String(io.gunzip(af.fromBase64(_res, true)))
_$o(_r, options)
}],
["oaf", (_res, options) => {
if (!isString(_res)) _exit(-1, "oaf is only supported with a string.")
_showTmpMsg()
var _r = af.eval(_res)
_$o(_r, options)
}],
["oafp", (_res, options) => {
params.__inception = true
var _r = _fromJSSLON(_res)
Expand Down
5 changes: 3 additions & 2 deletions src/include/outputFns.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,12 +282,13 @@ var _outputFns = new Map([
}],
["chart", (r, options) => {
if (isUnDef(params.chart)) _exit(-1, "For out=chart you need to provide a chart=\"<units> [<path[:color][:legend]>...]\"")
if (isUnDef(splitBySepWithEnc)) _exit(-1, "Output=chart is not supported in this version of OpenAF")
if (isUnDef(splitBySepWithEnc)) _exit(-1, "output=chart is not supported in this version of OpenAF")

let fmt = _chartPathParse(r, params.chart)
if (fmt.length > 0) {
var _out = printChart("oafp " + fmt)
if (toBoolean(params.chartcls)) cls()
_print(printChart("oafp " + fmt))
_print(_out)
}

}],
Expand Down

0 comments on commit ce4fca5

Please sign in to comment.