Releases: nette/command-line
Releases · nette/command-line
Released version 1.9.1
Released version 1.9.0
Requirements
- PHP 8.2 or higher is now required
New Features
Fluent API for Parser
New methods for defining options programmatically:
addSwitch()- adds a flag without value (e.g.--verbose)addOption()- adds an option with value (e.g.--format json)addArgument()- adds a positional argumentaddFromHelp()- extracts options from formatted help text
$parser = (new Parser)
->addSwitch('--verbose', '-v', description: 'Enable verbose mode')
->addOption('--format', '-f', optionalValue: true, fallback: 'json')
->addArgument('file');Early-Exit Parsing with parseOnly()
New method for parsing only specific options without validation:
// Check --help before full validation
if ($parser->parseOnly(['--help'])['--help']) {
$parser->help();
exit;
}
$args = $parser->parse(); // full parsing with validationUseful for --help and --version options that should work without providing required arguments.
Internal Changes
- Parser refactored to use
Optionobjects internally instead of arrays - Enum validation now runs before normalizer (BC break)
- Used
#[Deprecated]attribute for deprecated constants
Released version 1.8.3
- support for PHP 8.5
- optimized global function calls
Released version 1.8.2
support for PHP 8.4
Released version 1.8
requires PHP 8.0
Released version 1.7
- support for PHP 8.3
- Parser: added Normalizer
- constants are PascalCase
Released version 1.6
- updated detectColors()
Released version 1.5
- added Console::
detectColors() - requires PHP 7.2
For the details you can have a look at the diff.
Released version 1.4.0
- requires PHP 7.1
- uses PHP 7.1 features
- added PHP 7.1 scalar and return type hints
- added declare(strict_types=1);
Released version 1.3
- supports PHP up to 7.2
- coding style: fixes, lowercase true/false/null
For the details you can have a look at the diff.