I need some help. I am completely stumped. I’m trying to write my own tab completion module for a custom shell style program (also completing arguments) I can tab complete the commands, but the arguments are giving me trouble. Can some one write a sample tab completing module for me to look at?
Available Commands:
[‘show’,’exit’,’clear’, ‘ship’]
for command show, first arg:
[‘ip’,’mac’,’options’]
and for sub arg IP:
[‘external,’internal’,’local’]
In the end I want to be able to go:
My Prompt > sh<tab>
show ship
My Prompt > sho<tab>
My Prompt > show <tab>
ip mac options
My Prompt > show ip <tab>
external local internal
My Prompt > show ip e<tab>
My Prompt > show ip external
and so on an so forth. If I just had one good working example I think I could figure this out. I’ve completely rewritten my tab completion code 5 times, but still I can’t get it. Could some one please help?
In the end I figured it out after the 7th rewrite. A little messier than I would like, but workable, likely I will clean this up later. Anyways, here’s the code:
EDIT: Full code:http://codepad.org/W3VHURUx