Skip to content

Latest commit

 

History

History
88 lines (71 loc) · 1.82 KB

invoke-external-program.md

File metadata and controls

88 lines (71 loc) · 1.82 KB

Example: invoke program

invoke-program-config.yml

commands:
  - name: invoke-program
    description: invoke a program that prints the input params
    command: "./script.sh"
    options:
      - name: s
        optionType: String
        defaultValue: 'sValue'
      - name: a
        optionType: String
        defaultValue: 'aValue'
    positionalArguments:
      - name: foo
        description: foo argument
        type: StringList
        defaultValue: 'fooValue'
    # this is necessary when using relative paths for running a program
    runInConfigDirectory: true
    # omit this argument to treat positional arguments as options
    # (--foo will not be passed as an argument)
    positionalArgumentsAsOptions: true

script.sh

#!/bin/bash

echo "$@"

Usage

  • nca invoke-program -a hello -s world

    Output:

    // positionalArgumentsAsOptions: false (default)
    -a hello -s world fooValue
    // positionalArgumentsAsOptions: true
    -a hello -s world --foo fooValue
  • nca invoke-program -a hello -s world someValue

    Output:

    // positionalArgumentsAsOptions: false (default)
    -a hello -s world someValue
    // positionalArgumentsAsOptions: true
    -a hello -s world --foo someValue
  • nca invoke-program -a hello -s world someValue anotherValue

    Output:

    // positionalArgumentsAsOptions: false (default)
    -a hello -s world someValue,anotherValue
    // positionalArgumentsAsOptions: true
    -a hello -s world --foo someValue,anotherValue
  • nca invoke-program -a "hel lo" -s world "someValue anotherValue"

    Output:

    // positionalArgumentsAsOptions: false (default)
    -a hello -s world someValue anotherValue
    // positionalArgumentsAsOptions: true
    -a hel lo -s world --foo someValue anotherValue