switon/cli

Command surface with discovery, option binding, help output, and shell completion for Switon Framework

Maintainers

Package info

github.com/switon-php/cli

Documentation

pkg:composer/switon/cli

Statistics

Installs: 12

Dependents: 4

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-06-06 13:43 UTC

This package is auto-updated.

Last update: 2026-06-07 04:28:50 UTC


README

CI PHP 8.3+

Switon's CLI runtime for auto-discovered commands, help, and shell completion.

Highlights

  • 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.

Installation

composer require switon/cli

Quick Start

use 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 --shout

Docs: https://docs.switon.dev/latest/cli

License

MIT.