Skip to content

Option array type #26

@brad-jones

Description

@brad-jones

Thoughts on adding a new array option type. Which would then be an array of one of the existing types.

Given the following example task definition:

run-p:
  private: true
  usage: Parallel execution helper task
  options:
    commands:
      type: string
      required: true
    jobs:
      type: string
      default: 100%
  run: |
    parallel \
      --jobs ${jobs} \
      --keep-order \
      --line-buffer \
      --halt now,fail=1 \
      {} ::: ${commands}

And an example of how I am using it:

foo:
  usage: Runs some things in parallel
  run:
    task:
      name: run-p
      options:
        commands: '
          "ping -c 4 8.8.8.8"
          "ping -c 4 8.8.4.4"
        '

While this works and does the job for now, it would be nice if I could supply an array of strings to the task like this:

foo:
  usage: Runs some things in parallel
  run:
    task:
      name: run-p
      options:
        commands:
          - ping -c 4 8.8.8.8
          - ping -c 4 8.8.4.4

And then an example of what the run-p task definition might look like:

run-p:
  private: true
  usage: Parallel execution helper task
  options:
    commands:
      type: array
      required: true
      element-type: string
      delimiter: ","
    jobs:
      type: string
      default: 100%
  run: |
    parallel \
      --jobs ${jobs} \
      --keep-order \
      --line-buffer \
      --halt now,fail=1 \
      {} ::: \"$(X="${commands}"; echo $${X//,/\" \"})\"

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions