color print

Showcase a extended color print cmd, it is a improved cmd to support color printing for both plain text message, template rendering message and object

Demo

source

Main task yaml file
    tasks:
    - name: task
      task:
      - func: cmd
        vars:
          person:
            name: tom
            age: 18
          objectname: person
        do:
        - name: colorPrint
          cmd:
            msg: hello, world
            bg: blue
            fg: white
        - name: colorPrint
          cmd:
            msg: hello, world
            bg: yellow
        - name: colorPrint
          cmd:
            msg: hello, world
            fg: white
        - name: colorPrint
          cmd:
            msg: hello, world
        - name: colorPrint
          cmd:
            msg: '{{.person.name}}: {{.person.age}}'
            fg: blue
            bg: red
        - name: colorPrint
          cmd:
            object: 'person'
            fg: blue
            bg: black
        - name: colorPrint
          cmd:
            object: '{{.objectname}}'
            fg: blue
            bg: green
        - name: colorPrint
          cmd:
            object: 'person'
            msg: 'person'
            fg: blue
            bg: black
    
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 -> c0142
                 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/c0142
    module: [self], instance id: [dev], exec profile: []
    profile -  envVars:
    
    (*core.Cache)({
    })
    
    Task1: [task ==> task:  ]
    -Step1:
    self: final context exec vars:
    
    (*core.Cache)({
      "up_runtime_task_layer_number": 0,
      "person": {
        "name": "tom",
        "age": 18
      },
      "objectname": "person"
    })
    
    ~SubStep1: [colorPrint:  ]
    37 44
    hello, world
    ~SubStep2: [colorPrint:  ]
    37 44
    hello, world
    ~SubStep3: [colorPrint:  ]
    37 44
    hello, world
    ~SubStep4: [colorPrint:  ]
    37 44
    hello, world
    ~SubStep5: [colorPrint:  ]
    37 44
    tom: 18
    ~SubStep6: [colorPrint:  ]
    37 44
    object person:
     {
      "name": "tom",
      "age": 18
    }
    
    ~SubStep7: [colorPrint:  ]
    37 44
    object person:
     {
      "name": "tom",
      "age": 18
    }
    
    ~SubStep8: [colorPrint:  ]
    37 44
     WARN: [colorPrint] - [msg and object can not coexist]
    
Logs with different verbose level
Raw logs with different verbose level