Documentationcurrent version
Help us improve the docs by fixing typos and proposing enhancements.

Nikita

Metadata "raw"

The raw metadata property is an alias to define both the raw_input and the raw_output metadata properties.

  • Type: boolean
  • Default: false

Usage

The following example registers an action with raw enabled. It kind of behave just like a native JavaScript function if not the arguments which are destructured differently with args:

nikita
// Register an action
.registry.register('my_action', {
  metadata: {
    raw: true  },
  // Note, all options are optional
  handler: async function({args: [options={}, command='id -un']}) {
    let {stdout: who} = await this.execute(command, {trim: true})
    if (options.upper){
      who = who.toUpperCase() 
    }
    // Returned value
    return {who: who}
}})
.call(async function() {
  // Call the action with config
  const output = await this.my_action({upper: true}, 'whoami')  console.info(output)
  // Print something like `{who: "NIKITA"}`
})

For the sake of comparaison, the same code replacing raw with raw_input returns:

{ who: 'NIKITA', $status: true, $logs: [] }
Edit on GitHub
Navigate
About

Nikita is an open source project hosted on GitHub and developed by Adaltas.