Skip to content

Commit

Permalink
Add documentation about default command functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
kodie committed Nov 25, 2024
1 parent c354406 commit e59800f
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,21 @@ $app->add((new ConfigListCommand)->inGroup('Config'));
...
```

#### Default command

By default, running your CLI app without any arguments will show the help screen. However you can set the default action to run one of your commands either by setting the third parameter of the `add` function to `true` or by using the `defaultCommand` function.

```php
$app->add(new InitCommand, 'i', true);

# Alternatively
$app->command('init', 'Init something', 'i');
$app->defaultCommand('init');

# Retrieve the name of the default command
$default_command = $app->getDefaultCommand();
```

#### Exception handler

Set a custom exception handler as callback. The callback receives exception & exit code. The callback may rethrow exception or may exit the program or just log exception and do nothing else.
Expand Down

0 comments on commit e59800f

Please sign in to comment.