CliToolkit -> TODO
The list of plans and ideas for future development.
-
Docs:
- Array parameters (especially for
newArrayArgument()). - Validators custom exception messages.
- Details about Parametizer builder methods
(smart indent in
description, "allowed values" types (or completion only), required options, etc.).
- Array parameters (especially for
-
PHPUnit: the next major version.
- Try messing with the coverage.
-
Try out the parameters ambiguity puzzle:
-fctest, where-fis a flag,-cis an option and there is also a-tflag. Possible outcomes:testis the-cvalue,-tflag is not enabled.tesis the-cvalue andtis the-tflag being enabled.
-
HelpGenerator: show the same script path as used for calling it - by alias or by relative path.
-
(if possible) Auto-tests for Question.php.
-
Question.php: add a demo script showing different types of questions.
-
Flag+value combined options (
<no mention> | --verbose | --verbose=more).More details
Possible states:
- A parameter is not mentioned: the value is
nullorfalse. - A parameter is mentioned as a flag (no specific value): the value is
trueor some default. - A parameter is mentioned with a value.
See also symfony implementation as an example.
Points to consider:
- Solve the ambiguity:
- For
-voalways consider-vas an ordinal option (unless it is a flag-only option) andoas a value for-v. If-vis flag-only, thenoshould be a flag-like (a flag-only or a flag-or-option). -vvshould not be considered as the same flag mentioned twice (unless it is a flag-only option). It is an option-vwith a valuev.- For
-v moreconsidermoreas a value for-v(unless-vis a flag-only option). If you want to passmoreas an argument value and use flag-or-option-vas a flag, specify a double dash:-v -- more
- For
- Show explicitly such an option type on a generated help page.
Subtasks:
--help=moreshows hidden parameters (any visibility mask) like internal autocomplete-related parameters.
- A parameter is not mentioned: the value is
-
Class-based scripts as subcommands (Symfony-like).
Points to consider
-
Support
EnvironmentConfigsetup:- A script class skeleton should support a method to set an
EnvironmentConfiginstance received from a script launcher or (otherwise) created from scratch (including the config file autoloader).- If an
EnvironmentConfiginstance is passed from a launcher to a script class, it should be treated as a default config (not a forced only-config) - a script class should be able to update parameters.
- If an
- A script class skeleton should be also able to load an
EnvironmentConfiginstance from config files.- Think about the load priorities: a) launcher env config instance, b) script class subtree config files.
Base class implementation idea
<?php declare(strict_types=1); abstract class ParametizerPoweredAbstract { protected BuilderInterface $builder; public function __construct(protected ?EnvironmentConfig $launcherEnvConfig = null) { $this->builder = Parametizer::newConfig($this->createEnvironmentConfig()); } protected function createEnvironmentConfig(): EnvironmentConfig { // Start reading config files from the actual script classes directory. // 'x' should be calculated, but may be a hardcoded trace jumps count. $bottom = debug_backtrace()[last-x]; // Also test if __DIR__ placed as a default property value is transformed into // a current instance class directory, not the base abstract class directory. $envConfig = EnvironmentConfig::createFromConfigsBottomUpHierarchy($bottom); if (isset($this->launcherEnvConfig)) { // New method: fill only the settings not filled from config files. // But do it once (or mark all fields filled from files), // otherwise other attempts will overwrite all settings. $envConfig->appendNotFilledFromFiles($this->launcherEnvConfig); } return $envConfig; } abstract public function configure(): void; abstract public function execute(CliRequest $request): void; }
- A script class skeleton should support a method to set an
-
Support different script (subcommand) naming.
-
Composite names: 2 parts at least -
section:script(like in Symfony). Single named scripts should be allowed too.Also try to allow compositions of implement an ability to use any amount of parts (3, 4, ..., N).
-
Support single-named aliases:
cli-toolkit:generate-autocompletion-scriptsis the "main" name for a script, that may be also called viagasorgenerate-completionaliases. -
Ensure no names and aliases duplication.
-
-
Add built-in subcommand to list all detected scripts with their names and short descriptions.
-
Detected script names may be accessed as subcommand values by specifying their full names (autocomplete-powered) or unambiguous first characters substrings (like in Symfony console) - if there are scripts
clear-cacheandclone-config, the unambiguous enough substrings arecleandclorespectively.- (like in Symfony) In case of composite names each name substring should be mentioned - for
cli-toolkit:generate-autocompletion-scriptsyou should specifyc:g(if it is unambiguous enough - there are no other scripts namedc*:g*). - Support showing all available script names via the runner list command (switched on/off by a flag option).
- (like in Symfony) In case of composite names each name substring should be mentioned - for
-
Add a scripts launcher generator that initially stores a path to the CliToolkit engine.
In future, there may also be a path to a settings config file (see the "Environment Config" feature below) or the config contents itself.
-
Scripts launcher may detect ordinal Parametizer-based scripts (one of the launcher / "Environment Config" config settings).
Thoughts about such scripts naming:
- Generate default names by minimal unambiguous paths.
- Add a Parametizer config option to set a script name (and aliases). Use it as a way to detect such scripts and add those to a launcher available commands list.
-
-
A web interface for foreground / background scripts launch. Includes indications / notifications for finished (successfully or not) and halted (which require input from a user) scripts.
The web interface should be used as an example only - you may replace with with your own web or console interface. The main point is in the machinery behind the interface that you can reuse.
Let's try making major releases less frequent by accumulating here all ideas with backward incompatibilities. When the time comes, the whole bunch of stuff mentioned here will be implemented in a single major version.
- Move to PHP 8.4 as a minimal required version. This includes:
- Replace
*trim()functions withmb_*trim()alternatives.
- Replace
-
Fix the autocompletion "bug" case: with
-o1<tab>we expect the modified line-o100, but get100(-ois vanished).- Reason:
$COMP_WORDBREAKSshell variable is considered (notCompletion::COMP_WORDBREAKS), bash-completion sets the cursor after the last word break (before-o), so the rest (-o) is trimmed. - Possible, but odd solution: alter
$COMP_WORDBREAKSshell variable during runtime (append an option short name), then restore the variable's original value right before a script is terminated.
- Reason:
-
Complex validators for grouped or dependent parameters.
As for now, validators are fired only within connected parameters.
It would be cool to be able to validate a parameter "B" based on the pre-validated value of a parameter "A". Also if a validation exception happens, the generated help page should include all affected parameters ("A" and "B").
-
Simplify outputs strings formatting (TerminalFormatter) with something like tags.
More details
Something like
"value: '<itemValue>{$value}</itemValue>'"instead of"value: '" . $errorFormatter->itemValue($value) . "'". See also symfony coloring as an example.Points to consider:
- If formatting is disabled, the tags should be stripped from strings before outputting.
- Ignore (for formatting or stripping) not supported tags.
- Create a mean to escape a tag - to output it as is (for instance, as a formatting example).
- Use this feature to improve current built-in formatting - to simplify and shorten the code.
-
Symfony-like (or not like) progress bar.