Skip to content

Commit 1c0ccc0

Browse files
committed
Deprecate foreach-service
1 parent 8738fc9 commit 1c0ccc0

File tree

5 files changed

+5
-24
lines changed

5 files changed

+5
-24
lines changed

CLI.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ doco.cp() {
253253
Execute the given `doco` subcommand once for each service in the current service set, with the service set restricted to a single service for each subcommand invocation. This can be useful for explicit multiple (or zero) execution of a command that is otherwise restricted in how many times it can be executed.
254254

255255
```shell
256-
doco.foreach() { foreach-service doco "$@"; }
256+
doco.foreach() { target @current foreach doco "$@"; }
257257
```
258258

259259
#### `jq`

Services.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,6 @@ The services API depends on the [Targets API](Targets.md) and [bashup/events](ht
99

1010
### Automation
1111

12-
#### `foreach-service` *cmd args...*
13-
14-
Invoke *cmd args...* once for each service in the current service set; the service set will contain exactly one service during each invocation. Does nothing if the current service set is empty.
15-
16-
```shell
17-
foreach-service() { target @current foreach "$@"; }
18-
```
19-
2012
#### `have-services` *[compexpr]*
2113

2214
Return true if the current service count matches the bash numeric comparison *compexpr*; if no *compexpr* is supplied, returns true if the current service count is non-zero.
@@ -144,5 +136,6 @@ set-alias() { target "$1" set "$@"; }
144136
with-alias() { target "$1" call "${@:2}"; }
145137
with-service() { mdsh-splitwords "$1"; with-targets @current "${REPLY[@]}" -- "${@:2}"; }
146138
find-services() { services-matching "$@"; }
139+
foreach-service() { target @current foreach "$@"; }
147140
```
148141

bin/doco

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,6 @@ doco-target::get-env() {
714714
}
715715
716716
doco-target::with-env() { this get-env || return; local "${REPLY[@]}"; "$@"; }
717-
foreach-service() { target @current foreach "$@"; }
718717
have-services() { target @current has-count "$@"; }
719718
project-name() {
720719
REPLY=${COMPOSE_PROJECT_NAME-}
@@ -771,6 +770,7 @@ set-alias() { target "$1" set "$@"; }
771770
with-alias() { target "$1" call "${@:2}"; }
772771
with-service() { mdsh-splitwords "$1"; with-targets @current "${REPLY[@]}" -- "${@:2}"; }
773772
find-services() { services-matching "$@"; }
773+
foreach-service() { target @current foreach "$@"; }
774774
# doco opt OPTION CMD... --> run CMD with OPTION added to project options
775775
doco-opt() { local DOCO_OPTS=("${DOCO_OPTS[@]}" "$1"); "${@:2}"; }
776776
@@ -1004,7 +1004,7 @@ doco.cp() {
10041004
[[ "$seen" ]] || fail "cp: either source or destination must contain a :" || return
10051005
docker cp ${opts[@]+"${opts[@]}"}
10061006
}
1007-
doco.foreach() { foreach-service doco "$@"; }
1007+
doco.foreach() { target @current foreach doco "$@"; }
10081008
doco.jq() { RUN_JQ "$@" <"$DOCO_CONFIG"; }
10091009
doco.sh() { doco exec bash "$@"; }
10101010
DEFINE "${mdsh_raw_jq_api[*]}"

specs/Services.cram.md

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,6 @@
1414

1515
### Automation
1616

17-
#### `foreach-service` *cmd args...*
18-
19-
Invoke *cmd args...* once for each service in the current service set; the service set will contain exactly one service during each invocation.
20-
21-
~~~shell
22-
$ SERVICES foo bar
23-
$ with-targets foo bar -- foreach-service eval 'echo "${DOCO_SERVICES[@]}"'
24-
foo
25-
bar
26-
$ foreach-service eval 'echo "${DOCO_SERVICES[@]}"'
27-
~~~
28-
2917
#### `have-services` *[compexpr]*
3018

3119
Return true if the current service count matches the bash numeric comparison *compexpr*; if no *compexpr* is supplied, returns true if the current service count is non-zero.

specs/Targets.cram.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ Run *command* with a non-existent `@current` target.
314314

315315
#### `target` *target* `foreach` *command...*
316316

317-
Run *command* zero or more times, once for each service in *target*, with the current target set to the corresponding service.
317+
Run *command* zero or more times, once for each service in *target*, with the current target set to the corresponding service. Does nothing if the target is an empty group.
318318

319319
~~~shell
320320
$ target @current foreach declare -p DOCO_SERVICES # no entries; doesn't run

0 commit comments

Comments
 (0)