bashful

 ·  ☕ 2  · 👀...

介绍

技术 特性 适用场景 说明
bashful - 跨平台
- 串行或并行
- 日志记录
- yaml块配置任务
-命令失败时的详细错误报告
- 控制失败后是否停止执行
shell多任务 - Github

安装

1
2
> brew tap wagoodman/bashful
> brew install bashful
1
2
> wget https://github.com/wagoodman/bashful/releases/download/v0.0.10/bashful_0.0.10_linux_amd64.rpm
> rpm -i bashful_0.0.10_linux_amd64.rpm
1
2
> wget https://github.com/wagoodman/bashful/releases/download/v0.0.10/bashful_0.0.10_linux_amd64.deb
> sudo apt install ./bashful_0.0.10_linux_amd64.deb
1
> go get github.com/wagoodman/bashful 

Getting Started

语法

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
USAGE:
$ bashful run [options] <path-to-yaml-file>
$ bashful bundle <path-to-yaml-file>

COMMANDS:
     bundle   Bundle yaml and referenced url resources into a single executable
     run      Execute the given yaml

BUNDLE OPTIONS:
    None

RUN OPTIONS:

GLOBAL OPTIONS:
   --help, -h     show help
   --version, -v  print the version

yaml示例1

1
2
tasks:
    - cmd: echo "Hello, World!"

yaml示例2

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# ci.yaml
tasks:
    - name: Building app
      cmd: go build -ldflags '-linkmode external -extldflags -static -s'

    - name: Packaging app
      cmd: docker build -t my-awesome-app:v1 .

    - name: Publishing image
      cmd: docker push my-awesome-app:v1

    - name: Deploying app
      cmd: kubectl run my-awesome-app --image=docker.io/wagoodman/my-awesome-app:v1 --pt=80
1
2
3
# Run all of the tasks...
$ bashful run ci.yaml
# run just the build steps

yaml示例3

1
2
3
4
5
6
# install.yaml
tasks:
    - name: Installing bridgy
      parallel-tasks: 
        - cmd: sudo apt-get install -y tmux sshfs
        - cmd: pip install --user bridgy

yaml示例4

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
config:
    show-failure-report: false
    show-summary-errors: true
    max-parallel-commands: 6
    show-task-times: true

x-reference-data:
  all-apps: &app-names
    - some-lib-4
    - utilities-lib
    - important-lib
    - some-app1
    - some-app3

Configuration Options

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# this block is used to configure the look, feel, and behavior of all tasks
config:
    # which character used to delimintate the task list
    bullet-char: "-"

    # hide all child tasks after task section completion
    collapse-on-completion: false

    # change the colors of the vertical progress bar for a task in a particular state.
    # this should be a number from the 256 color palette.
    success-status-color: 10
    running-status-color: 22
    pending-status-color: 22
    error-status-color: 160

    # by default the screen is updated when an event occurs (when stdout from
    # a running process is read). This can be changed to only allow the 
    # screen to be updated on an interval (to accomodate slower devices).
    event-driven: false

    # This is the character/string that is replaced in the cmd section of a task to reference a downloaded url
    exec-replace-pattern: '<exec>'

    # the number of tasks that can run simultaneously
    max-parallel-commands: 4

    # log all task output and events to the given logfile
    log-path: path/to/file.log

    # show/hide the detailed summary of all task failures after completion
    show-failure-report: true

    # show/hide the last summary line (showing % complete, number of tasks ran, eta, etc)
    show-summary-footer: true

    # show/hide the number of tasks that have failed in the summary footer line
    show-summary-errors: false

    # show/hide the number of tasks completed thus far on the summary footer line
    show-summary-steps: true

    # show/hide the eta and runtime figures on the summary footer line
    show-summary-times: false

    # globally enable/disable showing the stdout/stderr of each task
    show-task-output: true

    # Show an eta for each task on the screen (being shown on every line with a command running)
    show-task-times: true

    # Show only one line of output to the screen (instead of a line per task + a summary line)
    single-line: true

    # globally enable/disable haulting further execution when any one task fails
    stop-on-failure: true

    # This is the character/string that is replaced with items listed in the 'for-each' block
    replica-replace-pattern: '<replace>'

    # time in milliseconds to update each task on the screen (polling interval)
    update-interval: 250

Wanglibing
Wanglibing
Engineer,Lifelong learner