Skip to content

Commit abf6fc0

Browse files
committed
Refactor and simplify docs
1 parent 6e174ed commit abf6fc0

8 files changed

Lines changed: 191 additions & 293 deletions

File tree

docs/basics.md

Lines changed: 33 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,24 @@
11
# Basics
22

3-
Deployer operates around two main concepts: [**hosts**](hosts.md) and [**tasks**](tasks.md). These are defined within a
4-
**recipe**, which is simply a file containing **hosts** and **tasks** definitions.
3+
Deployer is built around two concepts: [**hosts**](hosts.md) and [**tasks**](tasks.md). A **recipe** is a file
4+
that defines both.
55

6-
The Deployer CLI requires two arguments:
7-
8-
1. A **task** to execute.
9-
2. A **selector** to determine the hosts the task will run on.
10-
11-
Here's an example:
6+
The CLI takes two arguments — a task and a [selector](selector.md):
127

138
```sh
149
$ dep deploy deployer.org
1510
------ ------------
1611
task selector
1712
```
1813

19-
Deployer uses the [selector](selector.md) to choose which hosts to execute the task on. After selecting hosts, it
20-
prepares the environment (details later) and runs the task.
21-
2214
### Host Selection
2315

24-
- If no selector is specified, Deployer prompts you to choose a host.
25-
- If your recipe has only one host, it is automatically selected.
26-
- To run a task on all hosts, use the `all` selector.
16+
- No selector Deployer asks you to pick a host.
17+
- One host in the recipe — selected automatically.
18+
- `all` — every host.
2719

28-
By default, the `dep` CLI looks for a `deploy.php` or `deploy.yaml` file in the current directory. Alternatively, you
29-
can specify a recipe file explicitly using the `-f` or `--file` option:
20+
By default, `dep` loads `deploy.php` or `deploy.maml` from the current directory. Pass `-f` / `--file` to point it
21+
elsewhere:
3022

3123
```sh
3224
$ dep --file=deploy.php deploy deployer.org
@@ -36,7 +28,7 @@ $ dep --file=deploy.php deploy deployer.org
3628

3729
## Writing Your First Recipe
3830

39-
Here's an example of a simple recipe:
31+
A minimal recipe:
4032

4133
```php
4234
namespace Deployer;
@@ -48,7 +40,7 @@ task('my_task', function () {
4840
});
4941
```
5042

51-
To execute this task on `deployer.org`:
43+
Run it:
5244

5345
```sh
5446
$ dep my_task
@@ -57,8 +49,7 @@ task my_task
5749

5850
### Increasing Verbosity
5951

60-
By default, Deployer only shows task names. To see detailed output (e.g., the result of the `whoami` command), use the
61-
`-v` option:
52+
`dep` only shows task names by default. Use `-v` to see commands and their output:
6253

6354
```sh
6455
$ dep my_task -v
@@ -71,17 +62,17 @@ task my_task
7162

7263
## Working with Multiple Hosts
7364

74-
You can define multiple hosts in your recipe:
65+
Define more than one host:
7566

7667
```php
7768
host('deployer.org');
7869
host('medv.io');
7970
```
8071

81-
Deployer connects to hosts using the same `~/.ssh/config` file as the `ssh` command. Alternatively, you can
82-
specify [connection options](hosts.md) directly in the recipe.
72+
Deployer reads `~/.ssh/config` like the `ssh` command. You can also set [connection options](hosts.md) in the
73+
recipe.
8374

84-
Run a task on both hosts:
75+
Run a task on every host:
8576

8677
```sh
8778
$ dep my_task -v all
@@ -94,8 +85,8 @@ task my_task
9485

9586
### Controlling Parallelism
9687

97-
By default, tasks run in parallel on all selected hosts, which may mix the output. To limit execution to one host at a
98-
time:
88+
Tasks run in parallel on all selected hosts by default, which can interleave output. Use `--limit 1` to run one
89+
host at a time:
9990

10091
```sh
10192
$ dep my_task -v all --limit 1
@@ -106,20 +97,20 @@ task my_task
10697
[medv.io] deployer
10798
```
10899

109-
You can also specify a [limit level](tasks.md#limit) for individual tasks to control parallelism.
100+
Per-task limits are also available — see [limit](tasks.md#limit).
110101

111102
---
112103

113104
## Configuring Hosts
114105

115-
Each host can have a set of key-value configuration options. Here's an example:
106+
Each host carries key-value config:
116107

117108
```php
118109
host('deployer.org')->set('my_config', 'foo');
119110
host('medv.io')->set('my_config', 'bar');
120111
```
121112

122-
Access these options in a task using the [currentHost](api.md#currenthost) function:
113+
Read it inside a task with [currentHost](api.md#currenthost):
123114

124115
```php
125116
task('my_task', function () {
@@ -128,7 +119,7 @@ task('my_task', function () {
128119
});
129120
```
130121

131-
Or more concisely with the [get](api.md#get) function:
122+
Or shorter, with [get](api.md#get):
132123

133124
```php
134125
task('my_task', function () {
@@ -137,15 +128,15 @@ task('my_task', function () {
137128
});
138129
```
139130

140-
Or using brackets syntax `{{` and `}}`:
131+
Or inline with `{{...}}`:
141132

142133
```php
143134
task('my_task', function () {
144135
writeln("my_config: {{my_config}}");
145136
});
146137
```
147138

148-
To output literal `{{` without replacement, escape with a backslash `\{{`:
139+
Escape with a backslash to emit a literal `{{`:
149140

150141
```php
151142
run('echo \{{not_replaced}}'); // outputs: {{not_replaced}}
@@ -155,7 +146,7 @@ run('echo \{{not_replaced}}'); // outputs: {{not_replaced}}
155146

156147
## Global Configurations
157148

158-
Host configurations inherit global options. Here's how to set a global configuration:
149+
Hosts inherit global config:
159150

160151
```php
161152
set('my_config', 'global');
@@ -164,9 +155,7 @@ host('deployer.org');
164155
host('medv.io');
165156
```
166157

167-
Both hosts will inherit `my_config` with the value `global`. You can override these values for individual hosts as
168-
needed.
169-
158+
Both hosts now see `my_config = "global"`. Hosts can override:
170159

171160
```php
172161
set('my_config', 'global');
@@ -179,8 +168,7 @@ host('medv.io')->set('my_config', 'bar');
179168

180169
## Dynamic Configurations
181170

182-
You can define dynamic configuration values using callbacks. These are evaluated the first time they are accessed, and
183-
the result is stored for subsequent use:
171+
A callback value is evaluated on first access and cached:
184172

185173
```php
186174
set('whoami', function () {
@@ -203,7 +191,7 @@ task my_task
203191

204192
---
205193

206-
Dynamic configurations are cached after the first use:
194+
The cache is per-host: the callback runs once per host and the result sticks for the rest of the task tree.
207195

208196
```php
209197
set('current_date', function () {
@@ -217,8 +205,6 @@ task('my_task', function () {
217205
});
218206
```
219207

220-
Running this task:
221-
222208
```sh
223209
$ dep my_task deployer.org -v
224210
task my_task
@@ -233,7 +219,7 @@ task my_task
233219

234220
## Overriding Configurations via CLI
235221

236-
You can override configuration values using the `-o` option:
222+
Override any config value with `-o`:
237223

238224
```sh
239225
$ dep my_task deployer.org -v -o current_date="I don't know"
@@ -243,19 +229,19 @@ task my_task
243229
[deployer.org] What time is it? I don't know
244230
```
245231

246-
Since `current_date` is overridden, the callback is never executed.
232+
The callback never runs because `current_date` is already set.
247233

248234
:::note
249-
If you need to create a new configuration option based on the overridden one, use dynamic configuration syntax:
235+
To derive a value from a CLI-overridable config, use a callback. Plain `get()` at recipe load time captures the
236+
default and cannot see `-o` overrides.
250237

251238
```php
252-
253239
set('dir_name', 'test');
254240

255-
// calling get during recipe initialization will give you the original value defined above
241+
// Evaluated at recipe load — captures the default, ignores -o overrides.
256242
set('uses_original_dir_name', '/path/to/' . get('dir_name'));
257243

258-
// use dynamic configuration syntax if you need to get a value passed via -o option
244+
// Evaluated lazily — sees the overridden value.
259245
set('uses_overridden_dir_name', function () {
260246
return '/path/to/' . get('dir_name');
261247
});
@@ -273,8 +259,3 @@ task my_task
273259
[deployer.org] Path: /path/to/prod
274260
```
275261
:::
276-
277-
---
278-
279-
By now, you should have a solid understanding of Deployer’s basics, from defining tasks and hosts to working with
280-
configurations and dynamic values. Happy deploying!

docs/cli.md

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,51 @@
11
# CLI Usage
22

3-
We recommend adding the following alias to your .bashrc file:
3+
For project installs, alias `dep`:
44

55
```bash
66
alias dep='vendor/bin/dep'
77
```
88

9-
It is also recommended to install the completion script for Deployer. Completion supports:
10-
11-
- tasks,
12-
- options,
13-
- host names,
14-
- and configs.
15-
16-
For example, on macOS run the following commands:
9+
Install shell completion for tasks, options, host names, and configs. On macOS:
1710

1811
```bash
1912
brew install bash-completion
2013
dep completion bash > /usr/local/etc/bash_completion.d/deployer
2114
```
2215

16+
See [installation](installation.md#autocomplete-support) for zsh and fish.
17+
2318
## Overriding configuration options
2419

25-
For example, if your _deploy.php_ file contains this configuration:
20+
Use `-o` to override any config value at the command line. Given this in `deploy.php`:
2621

2722
```php
2823
set('ssh_multiplexing', false);
2924
```
3025

31-
And you want to enable [ssh multiplexing](https://en.wikibooks.org/wiki/OpenSSH/Cookbook/Multiplexing) without modifying the recipe, you can pass the `-o` option to the `dep` command:
26+
Re-enable [ssh multiplexing](https://en.wikibooks.org/wiki/OpenSSH/Cookbook/Multiplexing) for one run:
3227

3328
```
3429
dep deploy -o ssh_multiplexing=true
3530
```
3631

37-
To override multiple config options, you can pass multiple `-o` args:
32+
Pass `-o` multiple times to override more than one value:
3833

3934
```
4035
dep deploy -o ssh_multiplexing=true -o branch=master
4136
```
4237

4338
## Running arbitrary commands
4439

45-
Run any command on one or more hosts:
40+
Run an ad-hoc command on the selected hosts:
4641

4742
```
4843
dep run 'uptime -p'
4944
```
5045

5146
## Tree command
5247

53-
Deployer supports [task grouping](tasks.md#task-grouping) and [before/after hooks](tasks.md#addbefore).
54-
To visualize the task hierarchy, use the **dep tree** command.
48+
`dep tree <task>` visualizes [task grouping](tasks.md#task-grouping) and [before/after hooks](tasks.md#addbefore):
5549

5650
```
5751
$ dep tree deploy
@@ -81,8 +75,8 @@ The task-tree for deploy:
8175

8276
## Execution plan
8377

84-
Before executing tasks, Deployer needs to flatten the task tree and decide in which order it will be executing tasks
85-
on which hosts. Use the `--plan` option to output a table with tasks/hosts:
78+
Deployer flattens the task tree and decides task order per host before running. `--plan` prints the table without
79+
executing anything:
8680

8781
```
8882
$ dep deploy --plan all
@@ -113,7 +107,7 @@ $ dep deploy --plan all
113107
└──────────────────────┴──────────────────────┴──────────────────────┴──────────────────────┘
114108
```
115109

116-
The **deploy.php**:
110+
The `deploy.php` for the table above:
117111

118112
```php
119113
host('prod[01:04]');
@@ -122,17 +116,17 @@ task('deploy:symlink')->limit(1);
122116

123117
## The `runLocally` working dir
124118

125-
By default, `runLocally()` commands are executed relative to the recipe file directory.
126-
This can be overridden globally by setting an environment variable:
119+
`runLocally()` runs relative to the recipe file's directory by default. Override globally with an environment
120+
variable:
127121

128122
```
129-
DEPLOYER_ROOT=. dep taskname`
123+
DEPLOYER_ROOT=. dep taskname
130124
```
131125

132-
Alternatively, the root directory can be overridden per command via the cwd configuration.
126+
Or per call via the `cwd:` argument:
133127

134128
```php
135-
runLocally('ls', ['cwd' => '/root/directory']);
129+
runLocally('ls', cwd: '/root/directory');
136130
```
137131

138132
## Play blackjack

0 commit comments

Comments
 (0)