Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re^5: Using Tab Completion on Windows in cmd.exe

by Stamm (Sexton)
on Nov 26, 2011 at 13:51 UTC ( [id://940174]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Using Tab Completion on Windows in cmd.exe
in thread Using Tab Completion on Windows in cmd.exe

You're right, it doesn't work with Term::Complete. I thought I had tested it. As you said, it doesn't even use Term::ReadLine.

It works with Term::Shell. Here with the pod example slightly modified:
package MyShell; $ENV{TERM} = ''; use base qw(Term::Shell); sub run_command1 { print "command 1!\n"; } sub smry_command1 { "what does command1 do?" } sub help_command1 { "Help on 'command1', whatever that may be..." } sub run_command2 { print "command 2!\n"; } package main; my $shell = MyShell->new; $shell->cmdloop;

Or directly with Term::ReadLine:
use Term::ReadLine; $ENV{TERM} = ''; my $term = Term::ReadLine->new('Tab Completion'); my $prompt = ">>> "; &readline::rl_basic_commands( qw(set quit type test run exit) ); while ( defined ( $_ = $term->readline($prompt) ) ) { exit if /exit/ or /quit/; print $_, "\n"; }

Replies are listed 'Best First'.
Re^6: Using Tab Completion on Windows in cmd.exe
by Anonymous Monk on Nov 26, 2011 at 14:09 UTC

    Thank you, that seems usable

    For me, if i start typing something, and hit tab, it gets completed

    This i expected

    But if I only type tab, nothing happens until I hit tab again, at which point a newline is printed, then the available tab choices and a newline, then the prompt again

    This i didn't expect, I kinda expected it to cycle through list of completions, like cmd.exe does for filenames, like my demo from earlier, with shift+tab going in reverse (as is common, but which my version doesn't do)

    At least it usable

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://940174]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2025-06-22 08:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.