Skip to content

switon-php/command

Repository files navigation

Switon Command Package

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.

About

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

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages