在 Perl 脚本中,我使用Getopt::Complete
tab 键自动完成。一切都很好,除了我想实现的一个功能。
我想使用在某些情况下提供“目录”完成的回调。但是,从回调返回“目录”不起作用,因为需要数组引用。
use Getopt::Complete (
'<>' => sub {
my ( $command, $value, $option, $other_opts ) = @_;
if ( $other_opts->{'<>'} ) {
return 'directories'; ## here I'd like directory completion
}
return ['foo'];
}
);
如何实现这种行为?