Changes for version 0.055001 - 2022-02-12
- Enhancements
- Context-sensitive Completion / Validation `complete` methods now receive a second argument: a HashRef with "state" information that includes the preceding words on the command line (in the `$state->{processed}` ArrayRef) and a collection of options seen so far (in the `$state->{options}` HashRef).
- Argument validators also receive a "state" parameter HashRef (although it has a different different structure than that of `complete`, see documentation).
- See the demo script in `examples/context_sensitive_completion/`.
- Dynamic Enum Arguments The `value_list` of Term::CLI::Argument::Enum objects now accepts a CodeRef, which will be called when the list of values needs to be fetched.
- The new `values` method returns the actual list of values.
- The `cache_values` boolean attribute can be used to to execute the list expansion only once.
- The tutorial has been updated to include this.
- Dynamic Command Lists The `commands` argument of Term::CLI and Term::CLI::Commands objects (through Term::CLI::Role::CommandSet) now accepts a CodeRef, which will only be called the first time the command list is needed. This allows for delayed command building, which, if used in deeper levels of a command hierarchy, can reduce start-up time.
- A new `delete_command` method allows for dynamic command hierarchies [RFE#16]. See `examples/dynamic_commands.pl` for a demo of this.
- New `state` attribute for Term::CLI and Term::CLI::Command These classes now use a new role called Term::CLI::Role::State that provides a "state" HashRef that can be used to store application-specific state.
- Term::CLI Create a ReadLine object that uses `STDIN` and `STDOUT` by default, instead of letting (Gnu) ReadLine find and open the TTY separately. This ensures that:
- perl readline_app < input_file
- will actually read input from `input_file`, while also making sure that whatever encoding you have on the standard I/O handles (e.g. `use open qw(:std :utf8)`) will also be applied to ReadLine's I/O. This means that Estonians can write "tõsi" for "true" and Macedonians can write "лажни" for "false".
- Term::CLI::Argument::Boolean Completions now match the case of the partial text, so "TR" gets completed to "TRUE" instead of "TRue".
- Term::CLI::Role::CommandSet Command lists are now always sorted by name internally. This allows for optimised searching/matching.
- Term::CLI::Argument::Enum Value lists are always sorted internally. This allows for optimised searching/matching, see also examples/big_enum.pl
- Context-sensitive Completion / Validation `complete` methods now receive a second argument: a HashRef with "state" information that includes the preceding words on the command line (in the `$state->{processed}` ArrayRef) and a collection of options seen so far (in the `$state->{options}` HashRef).
- New
- Term::CLI::Util New module with a few utility functions for other modules.
- Term::CLI::Role::State A `Moo::Role` that adds a `state` hash to objects. See examples/state_demo.pl.
- benchmarks/* A few scripts with benchmarks for different approaches to particular algorithms.
- examples/cli_context.pl Demo script for CLI context (provided by djerius).
- Tests
- Various updates and fixes to test the new functionalities.
- Bug Fixes
- Term::CLI::Argument::Bool
- Fix case-sensitive completion (used `lc` where we shouldn't).
- Fix test cases for case-insenstive (enum) completion.
- tutorial/example_17_suspend.pl Don't suspend if there was an error on the command line input.
- Fix Boolean bug in tutorial (and accompanying code). We specified "1" as a valid value for "false"; that should be "0".
- Term::CLI::Argument::Bool
- Miscellaneous
- Eliminate unnecessary `shift` of function argument in favour of assigning from `@_`.
- Improve Dutch translation of "unknown (sub-)command"
- Fix dependency on Test::MockModule so it builds on FreeBSD 12.
- POD fixes and updates.
- Term::CLI::Command Modify error message for invalid arguments for readability.
Documentation
introduction to Term::CLI class/module structure
tips, tricks, and examples for Term::CLI
Modules
CLI interpreter based on Term::ReadLine
generic parent class for arguments in Term::CLI
class for "boolean" arguments in Term::CLI
class for "enum" string arguments in Term::CLI
class for file name arguments in Term::CLI
base class for numerical arguments in Term::CLI
class for floating point arguments in Term::CLI
class for integer arguments in Term::CLI
class for basic string arguments in Term::CLI
generic base class for Term::CLI classes
Class for (sub-)commands in Term::CLI
A generic 'help' command for Term::CLI
generic parent class for elements in Term::CLI
localizations for Term::CLI
English localizations for Term::CLI
Dutch localizations for Term::CLI
Term::ReadLine compatibility layer for Term::CLI
Manage command arguments in Term::CLI
Role for (sub-)commands in Term::CLI
Role for generating help text in Term::CLI
Keep a "state" hash in Term::CLI objects
utility functions for Term::CLI(3p)
Examples
- examples/big_enum.pl
- examples/cli_context.pl
- examples/context_sensitive_completion/README.md
- examples/context_sensitive_completion/cli_demo.pl
- examples/context_sensitive_completion/data/README.md
- examples/context_sensitive_completion/data/continents.json
- examples/context_sensitive_completion/data/countries.json
- examples/context_sensitive_completion/data/data.json
- examples/context_sensitive_completion/data/munge_country_data.pl
- examples/dynamic_commands.pl
- examples/getopt_test.pl
- examples/readline_cli.pl
- examples/readline_completion_demo.pl
- examples/simple_cli.pl
- examples/state_demo.pl
- examples/term_cli.pl
- examples/term_cli_demo.pl
- examples/wordlist-en.txt
Other files
- CONTRIBUTING.md
- Changes
- INSTALL
- LICENSE
- MANIFEST
- META.json
- META.yml
- Makefile.PL
- README.md
- cpanfile
- tutorial/example_01_basic_repl.pl
- tutorial/example_02_ignore_blank.pl
- tutorial/example_03_setting_prompt.pl
- tutorial/example_04_exit_command.pl
- tutorial/example_05_add_help.pl
- tutorial/example_06_add_help_text.pl
- tutorial/example_07_echo_command.pl
- tutorial/example_08_make_command.pl
- tutorial/example_09_ls_command.pl
- tutorial/example_10_cp_command.pl
- tutorial/example_11_sleep_command.pl
- tutorial/example_12_show_command.pl
- tutorial/example_13_set_command.pl
- tutorial/example_14_sub_cmd_and_args.pl
- tutorial/example_15_debug_command.pl
- tutorial/example_16_options.pl
- tutorial/example_17_suspend.pl
- tutorial/example_18_dynamic_enum.pl