rliebz / tusk

The modern task runner
https://rliebz.github.io/tusk/
MIT License
236 stars 21 forks source link

Support of variables and foreach #63

Open Hobart2967 opened 4 years ago

Hobart2967 commented 4 years ago

Is your feature request related to a problem? Please describe. Id like to see an option to set variables like real option values as shared variable.

Example:

vars:
  enabled-environments: &enabled-environments
    - dev
    - prod
    - all

tasks:
  build:
    options:
      environment:
        values: *enabled-environments
    run:
      - when: 
            equal: { environment: 'all' }
         task: build-all
      - when:
          not-equal: { environment: 'all' }
        run:
           yarn build:${environment}
  build-all:
    run:
      - foreach:
           list: ${vars.enabled-environments}
           as: current-environment
           task: # or run:
              name: build
              options:
                 environment: ${current-environment}

Describe the solution you'd like This makes it easier to build a cli with an include all or specific option.

rliebz commented 4 years ago

Thanks for opening an issue!

I see this is as related to https://github.com/rliebz/tusk/issues/26—a proper array type should eventually support both the "for each" construct, to let users call something once per item, and serialization, to let users input values as arrays into Tusk while passing them along to other programs.