Open fujiwara opened 2 weeks ago
external plugin runs any external commands as template functions.
The external plugin introduces functions to execute any external commands.
external
For example, jq -n "{ Now: now | todateiso8601" } returns the current date in ISO8601 format as a JSON object.
jq -n "{ Now: now | todateiso8601" }
$ jq -n "{ Now: now | todateiso8601 }" { "Now": "2024-10-25T16:13:22Z" }
You can use this command as a template function in the definition files.
First, define the plugin in the configuration file.
ecspresso.yml
plugins: - name: external config: name: jq command: ["jq", "-n"] num_args: 1 timeout: 5
The config section defines the following parameters:
config
name
command
num_args
parser
timeout
And use the template function in the definition files as follows.
local jq = std.native('jq'); { today: jq('{ Now: now | todateiso8601 }').Now, }
{ "today": "{{ (jq `{Now: now | todateiso8601}`).Now }}" }
external plugin runs any external commands as template functions.
Execute external commands
The
external
plugin introduces functions to execute any external commands.For example,
jq -n "{ Now: now | todateiso8601" }
returns the current date in ISO8601 format as a JSON object.You can use this command as a template function in the definition files.
First, define the plugin in the configuration file.
ecspresso.yml
The
config
section defines the following parameters:name
: template function namecommand
: external command and arguments (array)num_args
: number of arguments (optional, default 0)parser
: parser type "json" or "string" (optional, default "json")timeout
: command execution timeout seconds (optional, default never timeout)And use the template function in the definition files as follows.