Complete::Util - General completion routine
This document describes version 0.31 of Complete::Util (from Perl distribution Complete-Util), released on 2015-06-08.
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
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.
Will sort the resulting completion list, so you don't have to presort the array.
array* => array[str]
ci => bool
exclude => array
word* => str (default: "")
Complete from environment variables.
On Windows, environment variable names are all converted to uppercase. You can use case-insensitive option (ci) to match against original casing.
ci
Complete file and directory from local filesystem.
allow_dot => bool (default: 1)
If turned off, will not allow "." or ".." in path.
This is most useful when combined with starting_path option to prevent user going up/outside the starting path.
starting_path
Case-insensitive matching.
dig_leaf => bool
exp_im_path => bool
file_regex_filter => re
Filter shortcut for file regex.
This is a shortcut for constructing a filter. So instead of using filter, you use this option. This will construct a filter of including only directories or regular files, and the file must match a regex pattern. This use-case is common.
filter
filter => str|code
Only return items matching this filter.
Filter can either be a string or a code.
For string filter, you can specify a pipe-separated groups of sequences of these characters: f, d, r, w, x. Dash can appear anywhere in the sequence to mean not/negate. An example: f means to only show regular files, -f means only show non-regular files, drwx means to show only directories which are readable, writable, and executable (cd-able). wf|wd means writable regular files or writable directories.
f
-f
drwx
wf|wd
For code filter, you supply a coderef. The coderef will be called for each item with these arguments: $name. It should return true if it wants the item to be included.
$name
handle_tilde => bool (default: 1)
map_case => bool
starting_path => str (default: ".")
Complete from hash keys.
hash* => hash
Complete program name found in PATH.
Windows is supported, on Windows PATH will be split using /;/ instead of /:/.
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.
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::*
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.
perlancar <perlancar@cpan.org>
This software is copyright (c) 2015 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.