Skip to content

Commit

Permalink
adding 'chs' option
Browse files Browse the repository at this point in the history
  • Loading branch information
nmaguiar committed Jul 14, 2024
1 parent 70d8632 commit 5d05f6d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/docs/FILTERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ Using the same unix “pipe” mechanism it’s possible to apply different cate
| not_null(any) | base | Returns the non-null value between the provided fields | [].not_null(a,b) |
| now(diff) | 20240302 | Returns the current unix timestamp number with a negative diff (or positive for dates in the future) |
| nvl(field, value) | 20240216 | Returns the provided value in case a field value is undefined or null | nvl(nullField, 'n/a') |
| progress(value, max, min, size, indicator, space) | 20240712 | Returns a progress string to represent a value, between a max and a min, using an indicator char and space chars within a size limit | { val: v, p: progress(v, 100, 0, 10, __, __) } |
| replace(str, 're', 'flags', 'replaceText') | 20240209 | Equivalent to Javascript's replace function that given a string will search for a regular expression, with the optional flags, a replace with the provided text | replace('This is a test', ' a', 'i', ' not a') |
| reverse(array) | base | Reverse the provided array | "reverse(@)" |
| search_keys(arr, 'text') | all | Returns an array of entries where 'text' was found as part of an object property. | search_keys(files, 'filename') |
Expand Down
1 change: 1 addition & 0 deletions src/docs/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Takes an input, usually a data structure such as json, and transforms it to an e
| urlmethod | If 'url' is provided defines the http method to use if different from GET |
| urlparams | If 'url' is provided extra parameters (equivalent to OpenAF's $rest) can be provided in JSON/SLON |
| urldata | If 'url' is provided a JSON/SLON/text data can be provided |
| chs | A JSON/SLON map or array composed of an OpenAF channel 'name', 'type' and optional 'options' |
| loop | If defined will loop the processing by the number of seconds provided |
| loopcls | If 'true' and loop is defined it will clear the screen (or file) on each loop cycle |
| libs | Comma delimited list of installed OpenAF's oPacks to consider to extend oafp's inputs, transformations and outputs |
Expand Down
17 changes: 17 additions & 0 deletions src/oafp.source.js.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,23 @@ if (isDef(params.outfile)) {
global.__oafp_streams[params.outfile] = { s: io.writeFileStream(params.outfile, toBoolean(params.outfileappend)) }
}

// Check chs
if (isString(params.chs)) {
var _chs = af.fromJSSLON(params.chs)
if (!isArray(_chs)) _chs = [_chs]
_chs.forEach(ch => {
if (isMap(ch)) {
if (isString(ch.name) && isString(ch.type)) {
$ch(ch.name).create(ch.type, ch.options)
} else {
_exit(-1, "ERROR: chs must have a name and a type.")
}
} else {
_exit(-1, "ERROR: chs must be an object or array of objects with name and a type")
}
})
}

var _run = () => {
if (_version) {
_res = showVersion()
Expand Down

0 comments on commit 5d05f6d

Please sign in to comment.