cli tools/script runner
- PHP 100%
|
Thomas Ernst
5baddaa4be
All checks were successful
ci / ci (push) Successful in 1m12s
|
||
|---|---|---|
| .forgejo/workflows | Allow manual CI runs | |
| .github | Add GitHub mirror README | |
| docs | Format docs | |
| src | The big rename | |
| tests | The big rename | |
| .editorconfig | Sync shared config files | |
| .gitattributes | Update .gitattributes | |
| .gitignore | Update coverage path | |
| CHANGELOG.md | Update changelog | |
| composer.json | Require dev package v4.2 | |
| LICENSE.md | Update license | |
| mago.toml | Add mago config | |
| phpunit.xml.dist | Update coverage tools | |
| psalm.xml.dist | Rename phpunit and psalm config | |
| README.md | Update README badges | |
| run | Fix import paths | |
Celemas Cli
ci code coverage type coverage psalm level Software License
A command line interface helper.
Features
- Simple command creation with automatic help generation
- Built-in color support for terminal output
- Command-specific help with
php run help <command> - Built-in
commandscommand for shell autocomplete - Support for
--key=valueand--key valueoption syntax - Output helpers:
info(),success(),warn(),error(),echoln() - Text indentation and wrapping with
indent() - Debug mode for detailed error traces
- 100% test coverage
Installation
composer require celemas/cli
Quick Start
Create a command by extending Celemas\Cli\Command:
use Celemas\Cli\Command;
class MyCommand extends Command {
protected string $name = 'mycommand';
protected string $group = 'MyGroup';
protected string $description = 'This is my command';
public function run(): int
{
$this->info("Running my command");
$this->success("Command completed!");
return 0;
}
}
Create a runner script:
<?php
require __DIR__ . '/vendor/autoload.php';
use Celemas\Cli\{Runner, Commands};
$commands = new Commands([new MyCommand()]);
$runner = new Runner($commands);
$runner->run();
Run your command:
$ php run mycommand
Running my command
Command completed!
License
This project is licensed under the MIT license.