{"id":20094724,"url":"https://github.com/idearia/wp-cli-command","last_synced_at":"2025-05-06T04:32:47.206Z","repository":{"id":64271239,"uuid":"574622507","full_name":"Idearia/wp-cli-command","owner":"Idearia","description":"Simple class to create WP-CLI commands without effort","archived":false,"fork":false,"pushed_at":"2023-10-18T14:52:39.000Z","size":22,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-26T21:48:59.658Z","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/Idearia.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2022-12-05T18:02:53.000Z","updated_at":"2022-12-15T01:36:07.000Z","dependencies_parsed_at":"2024-11-16T16:32:29.469Z","dependency_job_id":"21f80acc-cf46-41be-b8c5-21b334f67719","html_url":"https://github.com/Idearia/wp-cli-command","commit_stats":{"total_commits":12,"total_committers":3,"mean_commits":4.0,"dds":0.5833333333333333,"last_synced_commit":"a0baf9988d35148db00e6391e425599614bd992f"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Idearia%2Fwp-cli-command","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Idearia%2Fwp-cli-command/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Idearia%2Fwp-cli-command/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Idearia%2Fwp-cli-command/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Idearia","download_url":"https://codeload.github.com/Idearia/wp-cli-command/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252622696,"owners_count":21778057,"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":[],"created_at":"2024-11-13T16:51:58.121Z","updated_at":"2025-05-06T04:32:46.915Z","avatar_url":"https://github.com/Idearia.png","language":"PHP","readme":"Simple class to create WP-CLI commands with validation with little effort.\n\n# Features\n\n- Create a WP CLI command by extending a simple class\n- Easily hook into the [command lifecycle](https://make.wordpress.org/cli/handbook/references/internal-api/wp-cli-add-hook/#notes) by extending methods `before_run_command`, `before_invoke`, `after_invoke`\n- Advanced validation by extending method `validate`\n- Support for sub-commands by defining public methods\n- Support for [PHPDoc validation](https://make.wordpress.org/cli/handbook/guides/commands-cookbook/#annotating-with-phpdoc)\n\n# Quick start\n\n1. Require `wp-cli-command` in your project:\n   ```\n   composer require idearia/wp-cli-command\n   ```\n2. Create a new command by extending the `Command` class. How? Have a look at the [examples folder](./examples) 🙂\n3. Register your command with `MyCommand::init( 'my-command' );`\n4. Run the command with `wp my-command`.\n\n# Available hooks\n\nIn oder of execution:\n\n- `before_run_command` \u003e Just before the command is found and executed\n- `before_invoke` \u003e Just before a command is invoked\n- `after_invoke` \u003e Just after a command is invoked\n\n# Example\n\n- A simple command from [WP-CLI docs](https://make.wordpress.org/cli/handbook/guides/commands-cookbook/#annotating-with-phpdoc) with an additional layer of validation: [examples/SimpleCommand.php](./examples/SimpleCommand.php)\n- An example with two sub-commands, each with its own validation \u003e TODO!\n\n# To do\n\n- Make hook methods aware of the specific command being executed, in case the class contains more than one. Probably, we will need to switch away from static, in order to save $args in the class.\n- Behat tests with [`wp scaffold package`](https://github.com/wp-cli/scaffold-package-command)\n- Example with subcommands\n- Find a way to execute PHPDoc validation before custom validation (maybe invoking the command and the exiting with `before_invoke:{$cmd}`)?\n- Find a way to print actual usage, instead of relying on $usage property (how to force show_usage in subcommand.php)?","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fidearia%2Fwp-cli-command","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fidearia%2Fwp-cli-command","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fidearia%2Fwp-cli-command/lists"}