netherphp / console
A CLI Parser
Installs: 2 873
Dependents: 6
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: >=8.0
- netherphp/object: >=4.1.4
- ramsey/uuid: ^4.1
- react/react: ^1.1
Requires (Dev)
- phpunit/phpunit: ^9.5
README
This package provides some basic functionality for creating command line interfaces via PHP 8 attributes.
Quickstart
require('vendor/autoloader.php'); use Nether\Console\Meta\Command; use Nether\Console\Meta\Info; use Nether\Console\Meta\Arg; use Nether\Console\Meta\Toggle; class App extends Nether\Console\Client { #[Command] #[Info('A whatever command.')] public function Whatever(): int { echo 'Whatever', PHP_EOL; return 0; } #[Command] #[Info('A whenever command.')] #[Arg('date', 'A date input.')] #[Toggle('-u', 'Output as unix time.')] public function Whenever(): int { $Date = $this->GetInput(1); $Unixise = $this->GetOption('u'); if($Unixise) echo date('U', strtotime($Date)); else echo date('Y-m-d', strtotime($Date)); echo PHP_EOL; return 0; } } exit((new App)->Run());
$ php ./test.php
USAGE: test.php <command> <args>
whatever
A whatever command.
whenever <date>
A whenever command.
-u
Output as unix time.