How to execute a tab in Perl Term :: Shell?

I use the Term :: Shell package in Perl to implement the CLI tool. I cannot complete tab completion with part of a command.

comp_CMD () is the API provided by this Term :: Shell, is to achieve tab completion. This does not help me. Does anyone know how to make this work?

Code example:

#!/usr/bin/env perl package Sample; use base qw(Term::Shell); sub prompt_str { "Sample\>" }; sub comp_show { my $o = shift; my $word = shift; $o->completions($word, [qw(all work and no play is no fun at)]); } sub run_show { print "run show\n"; } package main; Sample->new->cmdloop; 

This is the launch of the program:

 Sample>show[TAB] 

The above command does not give the expected result .. it just gives me a tab.

+4
source share
3 answers
+6
source

Your sample works for me. Both "show" and its arguments are completed.

After you type "show", there is nothing more to do, this is a complete command. To get the first argument, you must at least provide its first letter; therefore, typing <TAB> immediately after the show, you can only get you to where you need to type the first letter of the argument that you want to fill. And if you press <TAB> twice in a row, you will see what improvements are available.

The only thing that seemed strange to me is that if there is only one possible argument, it will not be automatically completed. You must still provide the first letter. This is a bit strange, but maybe just the supervision of the developer.

+2
source

First of all, I do not get the add comment button. Therefore, I am sending a message as a response.

I tried this way:

 sample> sh"TAB" sample>show w"TAB" 

Nothing succeeded.

Does this have anything to do with the environment? or something else?

0
source

All Articles