Skip to content

Commit 3e05837

Browse files
committed
docs: add Grouping commands section
1 parent 6c6e53c commit 3e05837

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,27 @@ $app->logo('Ascii art logo of your app');
231231
$app->handle($_SERVER['argv']); // if argv[1] is `i` or `init` it executes InitCommand
232232
```
233233

234+
#### Grouping commands
235+
236+
Grouped commands are listed together in commands list. Explicit grouping a command is optional.
237+
By default if a command name has a colon `:` then the part before it is taken as a group,
238+
else `*` is taken as a group.
239+
240+
> Example: command name `app:env` has a default group `app`, command name `appenv` has group `*`.
241+
242+
```php
243+
// Add grouped commands:
244+
$app->group('Configuration', function ($app) {
245+
$app->add(new ConfigSetCommand);
246+
$app->add(new ConfigListCommand);
247+
});
248+
249+
// Alternatively, set group one by one in each commands:
250+
$app->add((new ConfigSetCommand)->inGroup('Config'));
251+
$app->add((new ConfigListCommand)->inGroup('Config'));
252+
...
253+
```
254+
234255
#### App help
235256

236257
It can be triggered manually with `$app->showHelp()` or automatic when `-h` or `--help` option is passed to `$app->parse()`.

0 commit comments

Comments
 (0)