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

     1  doc_meta: |
     2    folder: loop
     3    title: condition with until
     4    head: |
     5      This showcases using until key word to exit loop
     6  
     7    sections:
     8      - title: Demo
     9        log: yes
    10  
    11  goal:
    12    - introduce until key word to exit loop
    13    - deom 3 loop cases
    14  
    15  tasks:
    16    -
    17      name: task
    18      desc: main entry
    19      task:
    20        -
    21          func: cmd
    22          name: step1
    23          desc: demo it will loop until loopitem = item3
    24          do:
    25            - name: print
    26              cmd: '{{.loopitem}}'
    27          loop:
    28            - item1
    29            - item2
    30            - item3
    31            - item4
    32          until: '{{ eq .loopitem "item3" }}'
    33  
    34        -
    35          func: cmd
    36          name: step2
    37          do:
    38            - name: print
    39              cmd: hello
    40  
    41        -
    42          func: call
    43          name: step3
    44          do: subtask
    45          loop:
    46            - proc 1
    47            - proc 2
    48            - proc 3
    49            - proc 4
    50          until: '{{ eq .loopitem "proc 3" }}'
    51  
    52        -
    53          func: call
    54          name: step4
    55          do: subtask
    56          loop:
    57            - proc 1
    58            - proc 2
    59            - proc 3
    60            - proc 4
    61          until: '{{ eq .loopindex 3 }}'
    62  
    63        -
    64          func: call
    65          name: step5
    66          desc: it will stop loop at proc 4
    67          vars:
    68            person: jason
    69          do: subtask2
    70          loop:
    71            - proc 1
    72            - proc 2
    73            - proc 3
    74            - proc 4
    75            - proc 5
    76            - proc 6
    77          until: '{{ eq .person "tom" }}'
    78  
    79    -
    80      name: subtask
    81      desc: subtask to test reg and return
    82      task:
    83        -
    84          func: cmd
    85          name: step1
    86          desc: the loopitem here is inherited from caller
    87          do:
    88            - name: print
    89              cmd: '{{.loopitem}}'
    90  
    91    -
    92      name: subtask2
    93      task:
    94        -
    95          func: cmd
    96          do:
    97            - name: reg
    98              cmd:
    99                name: person
   100                value: tom
   101          if: '{{ eq .loopindex 3 }}'
   102  
   103        -
   104          func: cmd
   105          name: step2
   106          do:
   107            - name: print
   108              cmd: 'person: {{.person}}'