【发布时间】:2016-05-13 22:57:08
【问题描述】:
我知道如何通过 Term::Readline::Gnu (Perl) 使用自定义完成函数,例如
str list_completion_function(str text, int state)
http://search.cpan.org/dist/Term-ReadLine-Gnu/Gnu.pm#Custom_Completion https://cnswww.cns.cwru.edu/php/chet/readline/readline.html#SEC47
$attribs->{attempted_completion_function } = sub {
my ($text, $line, $start, $end) = @_;
my @cmds = ('one', 'two', 'three');
$attribs->{completion_word} = \@cmds;
return $term->completion_matches($text, $attribs->{'list_completion_function'} );
};
..但我绝对不知道如何使用 complete_internal:
int rl_complete_internal(int what_to_do = TAB)
http://search.cpan.org/dist/Term-ReadLine-Gnu/Gnu.pm#Custom_Completion
来自 GNU Readline 文档:
?' means list the possible completions.TAB' 的值表示执行标准补全。 *' means insert all of the possible completions.!'表示显示所有可能的完成(...)
https://cnswww.cns.cwru.edu/php/chet/readline/readline.html#SEC47
这对我来说听起来像 gnu-readline 具有“类似cisco”/router-cli 模式 - 但也许我在这里完全错了?如果有这样的事情;如何使用 Term::Readline::Gnu 将自定义完成数据传递给它?
我搜索了 SO、GitHub Code、Google 等 pp,几乎肯定会错过(理解)一些东西。如果你能照亮我,那就太好了。
【问题讨论】:
标签: perl command-line-interface readline cisco