Releases: webisters/cli
Releases · webisters/cli
Release list
v2.0.0
Breaking Changes
Console::run()andConsole::exec()return the process exit code as anintinstead ofvoid. Callers can ignore the value, but a subclass that overrides either method with a: voidsignature has to be updated (#50)- An option declared with a type other than
flagand passed without a value is now a validation error instead of being silentlytrue(#38) - A command that declares
-hor--helpitself now receives that option instead of the console showing the auto generated help (#36)
New Features
- Space separated option values: an option declared in
$optionDefinitionswith a type other thanflagtakes the next token, so-o valueand--opt valuework next to--opt=value. A negative number like-5is an argument now and no longer needs the--marker (#48) - Commands decide the process exit code with
setExitCode(), returned byConsole::run()(#50) - Uncaught command exceptions are handled by the console:
setDebug()adds the class name and stack trace,setExceptionHandler()hands them to the application (#51) - Help output lists the argument and option definitions of a command (#49)
- Definition defaults are applied to arguments and options before the command runs (#39)
- New
flagoption type for options that are meant to be passed without a value (#38) NO_COLORandFORCE_COLORenvironment conventions are honoured (#47)- Validation errors are translatable, with
en,esandpt-brmessages (#55, thanks to @mahdyaralipor)
Fixes
- Validation messages and help output use the definition name instead of the array key (#54)
- Help is resolved through the command registry, and value arguments are skipped when looking for it (#36)
- Command suggestions only come from active commands and their aliases (#40)
CLI::strlen()strips arbitrary ANSI sequences, and style codes are cached (#45)CLI::style()validates colors and formats even when the terminal has no ANSI support (#44)- Quiet mode silences
progress(),spinner(),liveLine(),clear()andbeep()(#37) --quietand--no-ansiare scoped to their dispatch instead of leaking into the next one (#41)- An empty argument no longer raises a string offset warning in
Console::prepare()(#35) - composer.json requires only
ext-mbstring, the unused extension requirements are gone (#42)
Internal
- The test suite is platform independent and runs on Windows (#43)
- CI runs the tests on PHP 8.2, 8.3 and 8.4, and the lint and static analysis jobs are blocking (#53)
Documentation
v1.1.0
New Features
- Auto generated help output for
-hand--helpon any command (#2) - "Did you mean" suggestions for unknown command names, using Levenshtein distance (#3)
- Command aliases, so a command can be reached by multiple names (#4)
- Console wide quiet mode and
--no-ansi/-qglobal flags (#8) - Progress bar and spinner helpers (
CLI::progress(),CLI::spinner()) (#14) - Signal handling via pcntl:
CLI::onSignal(),CLI::onSigint(),CLI::restoreSignal()(#12) - Typed argument and option definitions with validation for commands (#6)
CLI::masked()prompt helper that echoes a mask character for sensitive input (#16)- PHPStan static analysis config and composer script (#10)
Fixes
- Declare required PHP extensions in composer.json (#1)
Documentation
- Real README overview of the CLI, Command and Console components (#5)
- Step by step guide to registering and running a custom command (#7)
- Docs for output, color and input helpers (#11)