basic cli skeleton

This showcases:
  • A typical cli application with user input
  • It taskes 2 envionrment vars and use default value if they are empty
  • Prepare the dynamic script(data) to be executed
  • Use a shell func to execute the final prepared script

Demo

source

Main task yaml file
    scopes:
    - name: global
      dvars:
      - name: student_name
        value: '{{ env "STUDENT_NAME" |default "Tom Hanks" }}'
      - name: student_age
        value: '{{ env "STUDENT_AGE" |default 28 }}'
    dvars:
    - name: cli
      desc: |
        you can offload this lengthy value to a ref file instead
        eventually the file will become a template file
      value: |
        echo """
        student details:
        name: {{.student_name}}
        age: {{.student_age}}
        """
    tasks:
    - name: task
      task:
      - func: shell
        do:
        - '{{.cli}}'
    
Main log file
    loading [Config]:  ./tests/functests/upconfig.yml
    Main config:
                 Version -> 1.0.0
                  RefDir -> ./tests/functests
                 WorkDir -> cwd
              AbsWorkDir -> /up_project/up
                TaskFile -> c0047
                 Verbose -> vvv
              ModuleName -> self
               ShellType -> /bin/sh
           MaxCallLayers -> 8
                 Timeout -> 3600000
     MaxModuelCallLayers -> 256
               EntryTask -> task
      ModRepoUsernameRef -> 
      ModRepoPasswordRef -> 
    work dir: /up_project/up
    -exec task: task
    loading [Task]:  ./tests/functests/c0047
    module: [self], instance id: [dev], exec profile: []
    profile -  envVars:
    
    (*core.Cache)({
    })
    
    Task1: [task ==> task:  ]
    -Step1:
    self: final context exec vars:
    
    (*core.Cache)({
      "student_name": "Tom Hanks",
      "student_age": "28",
      "cli": "echo \"\"\"\nstudent details:\nname: Tom Hanks\nage: 28\n\"\"\"\n",
      "up_runtime_task_layer_number": 0
    })
    
    cmd( 1):
    {{.cli}}
    
    -
    
    student details:
    name: Tom Hanks
    age: 28
    
    
    -
     .. ok
    . ok
    
Logs with different verbose level
Raw logs with different verbose level