Skip to content

Repository files navigation

Nether Console (netherphp/console)

PackagistBuild Statuscodecov

This package provides some basic functionality for creating command line interfaces via PHP 8 attributes.

Quickstart

require('vendor/autoloader.php');
useNether\Console\Meta\Command;
useNether\Console\Meta\Info;
useNether\Console\Meta\Arg;
useNether\Console\Meta\Toggle;
class App
extendsNether\Console\Client {
#[Command]
#[Info('A whatever command.')]
publicfunctionWhatever():
int {
echo'Whatever', PHP_EOL;
return0;
}
#[Command]
#[Info('A whenever command.')]
#[Arg('date', 'A date input.')]
#[Toggle('-u', 'Output as unix time.')]
publicfunctionWhenever():
int {
$Date = $this->GetInput(1);
$Unixise = $this->GetOption('u');
if($Unixise)
echodate('U', strtotime($Date));
elseechodate('Y-m-d', strtotime($Date));
echoPHP_EOL;
return0;
}
}
exit((newApp)->Run());
$ php ./test.php
USAGE: test.php <command> <args>
whatever
A whatever command.
whenever <date>
A whenever command.
-u
Output as unix time.

About

A CLI Parser.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages