switon/command

Shared command discovery and reflection metadata for CLI listings and AI tooling for Switon Framework

Maintainers

Package info

github.com/switon-php/command

Documentation

pkg:composer/switon/command

Statistics

Installs: 42

Dependents: 11

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 02:32:50 UTC


README

CI PHP 8.3+

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.