Complete::Util - General completion routine
This document describes version 0.46 of Complete::Util (from Perl distribution Complete-Util), released on 2016-04-05.
Make sure we return completion answer in array form.
This is the reverse of hashify_answer. It accepts a hash or an array. If it receives a hash, will return its words key.
hashify_answer
words
This function is not exported by default, but exportable.
Arguments ('*' denotes required arguments):
arg* => array|hash
Return value: (array)
Given two or more answers, combine them into one.
This function is useful if you want to provide a completion answer that is gathered from multiple sources. For example, say you are providing completion for the Perl tool cpanm, which accepts a filename (a tarball like *.tar.gz), a directory, or a module name. You can do something like this:
cpanm
*.tar.gz
combine_answers( complete_file(word=>$word, ci=>1), complete_module(word=>$word, ci=>1), );
If a completion answer has a metadata final set to true, then that answer is used as the final answer without any combining with the other answers.
final
$answers* => array[hash|array]
Return value: (hash)
Return a combined completion answer. Words from each input answer will be combined, order preserved and duplicates removed. The other keys from each answer will be merged.
Complete from array.
Try to find completion from an array of strings. Will attempt several methods, from the cheapest and most discriminating to the most expensive and least discriminating: normal string prefix matching, word-mode matching (see Complete::Common::OPT_WORD_MODE for more details), char-mode matching (see Complete::Common::OPT_CHAR_MODE for more details), and fuzzy matching (see Complete::Common::OPT_FUZZY for more details).
Complete::Common::OPT_WORD_MODE
Complete::Common::OPT_CHAR_MODE
Complete::Common::OPT_FUZZY
Will sort the resulting completion list, so you don't have to presort the array.
array* => array[str]
exclude => array
replace_map => hash
You can supply correction entries in this option. An example is when array if ['mount','unmount'] and umount is a popular "typo" for unmount. When someone already types um it cannot be completed into anything (even the current fuzzy mode will return both so it cannot complete immediately).
['mount','unmount']
umount
unmount
um
One solution is to add replace_map {'unmount'=>['umount']}. This way, umount will be regarded the same as unmount and when user types um it can be completed unambiguously into unmount.
{'unmount'=>['umount']}
word* => str (default: "")
Word to complete.
Complete from hash keys.
hash* => hash
Make sure we return completion answer in hash form.
This function accepts a hash or an array. If it receives an array, will convert the array into `{words=>$ary}' first to make sure the completion answer is in hash form.
Then will add keys from meta to the hash.
meta
meta => hash
Metadata (extra keys) for the hash.
If set to true, will display more log statements for debugging.
Can be used to force which levenshtein implementation to use. The default is to use XS version from Text::Levenshtein::XS if that module is installed, otherwise fallback to the included PP implementation (which is about 1-2 orders of magnitude slower).
Please visit the project's homepage at https://metacpan.org/release/Complete-Util.
Source repository is at https://github.com/perlancar/perl-Complete-Util.
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Complete-Util
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
Complete
If you want to do bash tab completion with Perl, take a look at Complete::Bash or Getopt::Long::Complete or Perinci::CmdLine.
Other Complete::* modules.
Complete::*
Bencher::Scenarios::CompleteUtil
perlancar <perlancar@cpan.org>
This software is copyright (c) 2016 by perlancar@cpan.org.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Complete::Util, copy and paste the appropriate command in to your terminal.
cpanm Complete::Util
CPAN shell
perl -MCPAN -e shell install Complete::Util
For more information on module installation, please visit the detailed CPAN module installation guide.