@@ -8,14 +8,11 @@ This example was generated with:
88``` bash
99$ bashly init
1010# ... now edit src/bashly.yml to match the example ...
11- # ... now edit src/lib/filter_docker_running.sh to match the example ...
12- # ... now edit src/lib/filter_redis_running.sh to match the example ...
11+ # ... now edit src/lib/filters.sh to match the example ...
1312$ bashly generate
1413```
1514
16- <!-- include: src/lib/filter_docker_running.sh src/lib/filter_redis_running.sh -->
17-
18- ---
15+ <!-- include: src/lib/filters.sh -->
1916
2017-----
2118
@@ -30,11 +27,11 @@ commands:
3027- name : container
3128 help : Perform actions on a docker container
3229
33- # The filters option can be a string or an array of strings.
3430 # When the command is executed, your script will look for a function named
3531 # "filter_docker_running" and execute it. If it prints a string, it will be
3632 # considered an error and the command execution will be halted.
37- filters : docker_running
33+ filters :
34+ - docker_running
3835
3936 args :
4037 - name : id
@@ -43,26 +40,30 @@ commands:
4340
4441- name : redis
4542 help : Perform actions in redis
46- filters : [docker_running, redis_running]
43+
44+ # When multiple filters are present, the command will halt if any of them
45+ # prints an error string.
46+ filters :
47+ - docker_running
48+ - redis_running
4749` ` `
4850
49- ## ` src/lib/filter_docker_running .sh`
51+ ## ` src/lib/filters .sh`
5052
5153` ` ` bash
54+ # These filter functions can reside in any path under the ` lib` directory.
55+ # You can use a single file for all filter functions, or a separate file
56+ # for each function.
57+
5258# Print an error string if docker is not running.
5359# The script will automatically exit if this function prints anything.
5460filter_docker_running() {
5561 docker info > /dev/null 2>&1 || echo "Docker must be running"
5662}
5763
58- ` ` `
59-
60- # # `src/lib/filter_redis_running.sh`
61-
62- ` ` ` bash
6364# This is just a sample filter designed to always fail
6465filter_redis_running() {
65- echo "Redis must be running (fake )"
66+ echo "Redis must be running (always fails )"
6667}
6768
6869```
8586### ` $ ./cli redis `
8687
8788``` shell
88- Redis must be running (fake )
89+ Redis must be running (always fails )
8990
9091
9192```
0 commit comments