Switon's CLI runtime for auto-discovered commands, help, and shell completion.
- Auto-discovered commands: package and app commands appear without manual registration.
- Multi-action commands: one command can expose several actions with shared help.
- Automatic options: action parameters become long options by default, with
#[ShortOption]for short aliases. - Inline help text: command help stays close to the code.
- Shell completion: the same command metadata feeds bash and zsh completion.
composer require switon/cliuse Switon\Core\Attribute\Autowired;
use Switon\Core\ConsoleInterface;
/**
* Send a greeting.
*/
class GreetCommand
{
#[Autowired] protected ConsoleInterface $console;
/**
* Say hello to one user.
*
* @param string $name Recipient name.
* @param bool $shout Uppercase the message.
*/
public function helloAction(string $name = 'world', bool $shout = false): void
{
$message = $shout ? 'HELLO, {name}!' : 'Hello, {name}!';
$this->console->success($message, ['name' => $name]);
}
}bash bin/console greet:hello --name=world --shoutDocs: https://docs.switon.dev/latest/cli
MIT.