{"id":17817144,"url":"https://github.com/ghostwriter/cli","last_synced_at":"2025-03-18T03:31:30.388Z","repository":{"id":257815532,"uuid":"855955447","full_name":"ghostwriter/cli","owner":"ghostwriter","description":"[WIP]Provides a micro-framework for building CLI tools in PHP.","archived":false,"fork":false,"pushed_at":"2025-03-15T18:25:57.000Z","size":303,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"0.1.x","last_synced_at":"2025-03-15T19:28:04.085Z","etag":null,"topics":["cli","cli-wrapper","ghostwriter"],"latest_commit_sha":null,"homepage":"https://github.com/ghostwriter/cli","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ghostwriter.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["ghostwriter"]}},"created_at":"2024-09-11T18:26:04.000Z","updated_at":"2025-03-15T18:26:00.000Z","dependencies_parsed_at":"2025-01-08T02:27:53.595Z","dependency_job_id":"b65c752e-4a5c-49fb-b5e1-77a38ce023df","html_url":"https://github.com/ghostwriter/cli","commit_stats":null,"previous_names":["ghostwriter/cli"],"tags_count":0,"template":false,"template_full_name":"ghostwriter/wip","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghostwriter%2Fcli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghostwriter%2Fcli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghostwriter%2Fcli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghostwriter%2Fcli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ghostwriter","download_url":"https://codeload.github.com/ghostwriter/cli/tar.gz/refs/heads/0.1.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243897011,"owners_count":20365485,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","cli-wrapper","ghostwriter"],"created_at":"2024-10-27T16:40:56.306Z","updated_at":"2025-03-18T03:31:30.376Z","avatar_url":"https://github.com/ghostwriter.png","language":"PHP","readme":"# Cli\n\n[![GitHub Sponsors](https://img.shields.io/github/sponsors/ghostwriter?label=Sponsor+@ghostwriter/cli\u0026logo=GitHub+Sponsors)](https://github.com/sponsors/ghostwriter)\n[![Automation](https://github.com/ghostwriter/cli/actions/workflows/automation.yml/badge.svg)](https://github.com/ghostwriter/cli/actions/workflows/automation.yml)\n[![Supported PHP Version](https://badgen.net/packagist/php/ghostwriter/cli?color=8892bf)](https://www.php.net/supported-versions)\n[![Downloads](https://badgen.net/packagist/dt/ghostwriter/cli?color=blue)](https://packagist.org/packages/ghostwriter/cli)\n\nProvides a micro-framework for building CLI tools in PHP.\n\n\u003e [!WARNING]\n\u003e\n\u003e This project is not finished yet, work in progress.\n\n## Installation\n\nYou can install the package via composer:\n\n``` bash\ncomposer require ghostwriter/cli\n```\n\n### Star ⭐️ this repo if you find it useful\n\nYou can also star (🌟) this repo to find it easier later.\n\n## Usage\n\n```php\n\u003c?php declare(strict_types=1);\n\nnamespace Vendor\\Project;\n\nuse GhostWriter\\Cli\\Attribute\\Application;use GhostWriter\\Cli\\Attribute\\Argument;use GhostWriter\\Cli\\Attribute\\Command;use GhostWriter\\Cli\\Attribute\\Option;use Ghostwriter\\Cli\\Core\\MiddlewareInterface;\n\n#[Command(name: 'new', description: 'Create a new project')]\nfinal class NewCommand\n{\n    #[Argument(help: 'Project name')]\n    public string $name;\n    #[Option(short: 't', long: 'type', help: 'Project type')]\n    public string $type = 'php';\n    #[Option(short: 'd', long: 'directory', help: 'Project directory')]\n    public string $directory;\n}\n\n#[Command(name: 'help', description: 'Show help')]   \nfinal class HelpCommand\n{\n    #[Argument(help: 'Command to show help for')]\n    public ?string $command = null;\n}\n\n#[Command(name: 'list', description: 'List all projects')]\nfinal class ListCommand\n{\n    #[Option(short: 't', long: 'type', help: 'Project type')]\n    public string $type = 'php';\n}\n\nfinal readonly class GitHubAuthMiddleware implements MiddlewareInterface\n{\n    public function __construct(private string $token) {}\n\n    #[Override]\n    public function process(CommandInterface $command, HandlerInterface $handler): ResultInterface\n    {\n        $command-\u003eenv['GITHUB'] = $this-\u003etoken;\n\n        return $handler-\u003ehandle($command);\n    }\n}\n\n#[Application(\n    package: 'ghostwriter/architect',\n    commands: [NewCommand::class, HelpCommand::class, ListCommand::class],\n    middlewares: [GitHubAuthMiddleware::class]\n)]\nfinal class Architect\n{\n    // Default options available in all subcommands (help, version)\n    #[Option(short: 'h', long: 'help', help: 'Show help')]\n    public bool $help = false;\n\n    #[Option(short: 'v', long: 'version', help: 'Show version')]\n    public bool $version = false;\n    \n    // Custom optional options (with default values)\n    #[Option(short: 'b', long: 'bool', help: 'Set the boolean flag')]\n    public bool $bool = false;\n    \n    #[Option(short: 'f', long: 'float', help: 'Set the float to \u003cfloat\u003e')]\n    public float $float = 0.0;\n    \n    #[Option(short: 'i', long: 'int', help: 'Set the integer to \u003cint\u003e')]\n    public int $int = 0;\n    \n    #[Option(short: 's', long: 'string', help: 'Set the string to \u003cstring\u003e')]\n    public string $string = '#BlackLivesMatter';\n    \n    #[Option(short: 'l', long: 'list', help: 'Set the list to \u003clist\u003e')]\n    public array $list = [];\n    \n    #[Option(short: 'n', long: 'null', help: 'Set the null to \u003cnull\u003e')]\n    public ?string $null = null;\n    \n    // Custom required options\n    #[Option(short: 'r', long: 'required', help: 'Set the required to \u003crequired\u003e', required: true)]\n    public string $required;\n    \n    // Required arguments\n    #[Argument(help: 'Project name')]\n    public string $project;\n    \n    // Optional arguments (with default values)\n    #[Argument(help: 'Project directory')]\n    public string $directory = '.';\n}\n\n$exitCode = \\GhostWriter\\Cli\\Application::new(Architect::class)-\u003erun($_SERVER['argv']);\nexit($exitCode);\n```\n\n### Credits\n\n- [Nathanael Esayeas](https://github.com/ghostwriter)\n- [All Contributors](https://github.com/ghostwriter/cli/contributors)\n\n### Changelog\n\nPlease see [CHANGELOG.md](./CHANGELOG.md) for more information on what has changed recently.\n\n### License\n\nPlease see [LICENSE](./LICENSE) for more information on the license that applies to this project.\n\n### Security\n\nPlease see [SECURITY.md](./SECURITY.md) for more information on security disclosure process.\n","funding_links":["https://github.com/sponsors/ghostwriter"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fghostwriter%2Fcli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fghostwriter%2Fcli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fghostwriter%2Fcli/lists"}