github.com/upcmd/up@v0.8.1-0.20230108151705-ad8b797bf04f/tests/functests/c0127.yml (about)

     1  doc_meta: |
     2    folder: flow-controll
     3    title: else branch
     4    head: |
     5      Introduce the else element, with an array of tasks for detailed implementations
     6  
     7    sections:
     8      - title: Demo
     9        log: yes
    10  
    11  notes:
    12    goal:
    13      - intro the 2nd solution doing else
    14      - add feature of else element
    15  
    16  vars:
    17    goahead: False
    18  #  goahead: True
    19  
    20  tasks:
    21  
    22    - name: task
    23      task:
    24  
    25        - func: cmd
    26          do:
    27            -
    28              name: print
    29              cmd: |
    30                true/false value of goahead:
    31                {{.goahead}}
    32                {{not .goahead}}
    33  
    34        - func: call
    35          desc: show example the route goes to call goelse for the condition of not if condition succeeds
    36          do:
    37            - goahead
    38          if: '{{.goahead}}'
    39          else: goelse
    40  
    41        - func: call
    42          desc: show example the else coud route to call a list of tasks
    43          do:
    44            - goahead
    45          if: '{{.goahead}}'
    46          else:
    47            - goelse
    48            - goelse
    49            - goelse2
    50            - goelse2
    51  
    52        - func: call
    53          desc: show it is same that you could assemble a list of tasks for if true condition
    54          vars:
    55            goahead: True
    56          do:
    57            - goahead
    58            - goahead
    59            - goahead
    60          if: '{{.goahead}}'
    61          else:
    62            - goelse
    63            - goelse
    64            - goelse2
    65            - goelse2
    66  
    67    - name: goahead
    68      task:
    69        - func: cmd
    70          do:
    71            -
    72              name: print
    73              cmd: 'go ahead .......'
    74  
    75    - name: goelse
    76      task:
    77        - func: cmd
    78          do:
    79            -
    80              name: print
    81              cmd: 'do something else .......'
    82  
    83    - name: goelse2
    84      task:
    85        - func: cmd
    86          do:
    87            -
    88              name: print
    89              cmd: 'do something else2 .......'