.NET Console Application Tab Completion

Do a Console.ReadKey().

If you get a Tab, look at what you have in the command buffer, and loop through your available commands. If someCommand.Name.BeginsWith(currentinput), you have a winner, and you can write to screen a list of possible commands.

If there is only one(TM) you can substitute it with what the user had typed :)


Console.ReadKey


Take a look at this code from the Mono project http://tirania.org/blog/archive/2008/Aug-26.html I played with it some the other day. It does a lot of command line editingy, but I don't think it does line completion.


I created a small lib to add this functionality to an app i made:

https://github.com/fjunqueira/hinter

It might not suit your needs, but you can feel free to edit it.

Tags:

.Net

Console