{"id":42689363,"url":"https://github.com/php-tui/cli-parser","last_synced_at":"2026-01-29T12:46:37.698Z","repository":{"id":218991338,"uuid":"746368086","full_name":"php-tui/cli-parser","owner":"php-tui","description":"Type-safe CLI argument parser","archived":false,"fork":false,"pushed_at":"2024-07-29T21:58:23.000Z","size":89,"stargazers_count":9,"open_issues_count":2,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-07-30T03:43:51.193Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/php-tui.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-21T20:55:10.000Z","updated_at":"2024-07-29T21:58:26.000Z","dependencies_parsed_at":"2024-02-03T15:24:49.591Z","dependency_job_id":"2fccabb6-6171-4117-b6f5-6e7f200a4b8e","html_url":"https://github.com/php-tui/cli-parser","commit_stats":null,"previous_names":["php-tui/cli-parser"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/php-tui/cli-parser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-tui%2Fcli-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-tui%2Fcli-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-tui%2Fcli-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-tui%2Fcli-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/php-tui","download_url":"https://codeload.github.com/php-tui/cli-parser/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-tui%2Fcli-parser/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28877877,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-29T10:31:27.438Z","status":"ssl_error","status_checked_at":"2026-01-29T10:31:01.017Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2026-01-29T12:46:35.707Z","updated_at":"2026-01-29T12:46:37.686Z","avatar_url":"https://github.com/php-tui.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"CLI Parser and Handler\n======================\n\n\u003e warning: don't usr this, it's a failed experiment!\n\nType safe CLI parser and command handler for PHP inspired by [Kong](https://github.com/alecthomas/kong).\n\nFeatures\n--------\n\n- Casts arguments and options into objects.\n- Command bus and middleware architecture.\n- Parsing\n  - Command nesting\n  - Type support for `string`, `int`, `float`, `boolean` and `lists`.\n  - Repeated arguments\n  - Optional arguments\n  - Long and short options\n  - Boolean options (flags)\n  - List options\n\nUsage Example\n-------------\n\n```php\n\u003c?php\n\nuse PhpTui\\CliParser\\ApplicationBuilder;\nuse PhpTui\\CliParser\\Application\\Context;\nuse PhpTui\\CliParser\\Application\\Middleware\\ExceptionHandlingMiddleware;\nuse PhpTui\\CliParser\\Application\\Middleware\\HelpMiddleware;\nuse PhpTui\\CliParser\\Attribute\\App;\nuse PhpTui\\CliParser\\Attribute\\Cmd;\nuse PhpTui\\CliParser\\Attribute\\Opt;\nuse PhpTui\\CliParser\\Attribute\\Arg;\nuse PhpTui\\CliParser\\Printer\\AsciiPrinter;\n\n#[App(name: 'Git', version: '1.0', author: 'Daniel Leech')]\nfinal class GitCmd\n{\n    public CloneCmd $clone;\n\n    public InitCmd $init;\n\n    #[Opt(short: 'v', long: 'version', help: 'Create an empty git repository')]\n    public bool $version = false;\n\n    #[Opt(help: 'Show help')]\n    public bool $help = false;\n\n    #[Opt(short: 'C', help: 'Run git as ig it were executed in this path')]\n    public string $cwd;\n}\n\n#[Cmd(help: 'Clone a repository into a new directory')]\nfinal class CloneCmd\n{\n    #[Arg(help: 'Repository to clone', required: true)]\n    public string $repo;\n\n    #[Opt(name: 'recurse-submodules', short: 'R', help: 'Initialize submodules in the clone')]\n    public bool $recurseSubModules = false;\n}\n\n#[Cmd(help: 'Create an empty git repository')]\nfinal class InitCmd\n{\n    #[Arg(help: 'Repository to clone')]\n    public string $repo;\n\n    #[Opt(name: 'recurse-submodules', help: 'Initialize submodules in the clone')]\n    public bool $recurseSubModules;\n}\n\n$cli = new GitCmd();\n$cli-\u003einit = new InitCmd();\n$cli-\u003eclone = new CloneCmd();\n\n$application = ApplicationBuilder::fromSpecification($cli)\n    -\u003eprependMiddleware(new HelpMiddleware(new AsciiPrinter()))\n    -\u003eaddHandler(InitCmd::class, function (Context $ctx) {\n        echo 'Initializing' . \"\\n\";\n        return 0;\n    })\n    -\u003eaddHandler(CloneCmd::class, function (Context $ctx) {\n        echo sprintf('Git cloning %s...', $ctx-\u003ecommand()-\u003erepo) . \"\\n\";\n        if ($ctx-\u003ecommand()-\u003erecurseSubModules) {\n            echo '... and recursing submodules' . \"\\n\";\n        }\n        return 0;\n    })\n    -\u003ebuild();\n\nexit($application-\u003erun($argv));\n```\n\nContribution\n------------\n\nContribute!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp-tui%2Fcli-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphp-tui%2Fcli-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp-tui%2Fcli-parser/lists"}