Skip to content

Latest commit

 

History

History
54 lines (43 loc) · 1009 Bytes

function-positional-arguments.md

File metadata and controls

54 lines (43 loc) · 1009 Bytes

Example: function

commands:
  - name: log-positional
    description: positional arguments logger
    command: |
      console.log(input.args.foo);
      console.log(input.args.bar);
      console.log(input.args.baz);
    commandType: Function
    positionalArguments:
      - name: foo
        description: foo argument
        type: Boolean
        defaultValue: false
      - name: bar
        description: bar argument
        type: Number
      - name: baz
        description: baz argument
        type: StringList

Usage

  • nca log-positional 1 a b
    

    Output:

    false
    1
    [ 'a', 'b' ]
  • nca log-positional --foo=true 1 a b
    

    Output:

    true
    1
    [ 'a', 'b' ]

Notes

Try to always put optional positional arguments after the required ones, otherwise the engine could not behave as expected. As a matter of fact, the second example shows that to change foo default value it needs to be specified as an optional parameter.