switon / command
Shared command discovery and reflection metadata for CLI listings and AI tooling for Switon Framework
v1.0.0
2026-06-06 13:43 UTC
Requires
- php: >=8.3
- switon/composer-extra: ^1.0
- switon/core: ^1.0
Requires (Dev)
- phpstan/extension-installer: ^1.4
- phpstan/phpstan: ^2.0
- switon/testing: ^1.0
README
Switon's command metadata layer for auto-discovery, PHPDoc help, AI synopses, and short-option aliases.
Highlights
- Automatic discovery: package commands come from
extra.switon.commands, and app commands are scanned automatically. - Docblock help: command help comes from class and action docblocks.
- AI synopsis:
#[Tool]adds an AI-facing synopsis for an action. - Visibility controls:
#[Hidden]can hide a command or action from default listings. - Explicit option aliases:
#[ShortOption]pins short aliases where needed.
Installation
composer require switon/command
Quick Start
use Switon\Command\Attribute\ShortOption; use Switon\Command\Attribute\Tool; /** * Report commands. */ final class ReportCommand { /** * Return a report summary. * * @param string $id Report id to inspect * @param bool $shout Uppercase the output */ #[Tool('Returns JSON report summary by id.')] public function statusAction(#[ShortOption('x')] string $excluded, bool $shout = false): array { return ['excluded' => $excluded, 'shout' => $shout]; } }
CommandInspector feeds cli help/list output and beacon JSON tool metadata.
Rendered from the example above:
report Report commands.
report:status Return a report summary.
Option Description Default
--excluded, -x Excluded id to inspect
--shout, -s Uppercase the output false
Docs: https://docs.switon.dev/latest/command
License
MIT.