github.com/tooploox/oya@v0.0.21-0.20230524103240-1cda1861aad6/features/flags.feature (about)

     1  Feature: Running tasks
     2  
     3  Background:
     4     Given I'm in project dir
     5  
     6  Scenario: Pass flags and positional arguments to a task
     7    Given file ./Oyafile containing
     8      """
     9      Project: project
    10      task: |
    11        for i in $*; do
    12          echo $i
    13        done
    14  
    15        echo ${Oya[Args.0]}
    16        echo ${Oya[Args.1]}
    17  
    18        echo --switch = ${Oya[Flags.switch]}
    19        echo --value = ${Oya[Flags.value]}
    20        echo --other-switch = ${Oya[Flags.otherSwitch]}
    21      """
    22    When I run "oya run task --switch positional1 --value=5 positional2 --other-switch"
    23    Then the command succeeds
    24    And the command outputs
    25    """
    26    --switch
    27    positional1
    28    --value=5
    29    positional2
    30    --other-switch
    31    positional1
    32    positional2
    33    --switch = true
    34    --value = 5
    35    --other-switch = true
    36  
    37    """
    38  
    39  Scenario: Have args survive 'set' command (regression)
    40    Given file ./Oyafile containing
    41      """
    42      Project: project
    43      task: |
    44        set -e
    45        echo $1
    46  
    47      """
    48    When I run "oya run task arg"
    49    Then the command succeeds
    50    And the command outputs
    51    """
    52    arg
    53  
    54    """