I'm considering writing a console application in C# and I want to incorporate history, completion and command line editing features something like GNU readline (but not necessarily as extensive as that!)
Is there an existing library for .net which provides this type of functionality? I guess one option would be to use interop services to call GNU readline. But is there a native option?
You may want to checkout Miguel de Icaza's getline.cs (the link in the blog post is broken, the code can now be found here). Depending on what features of readline you actually need, it might be enough for your purposes.
The nice thing is, that it is all contained in a single (hence getline.cs) file and MIT X11 licensed.
Using it is pretty easy.
If you want to give it try, just download the file and compile it:
C:\> csc.exe /d:DEMO getline.cs
C:\> getline.exe
shell>
The #ifdef DEMO
part also shows the basic REPL:
var le = new LineEditor("whatever");
string s;
while ((s = le.Edit("my prompt> ", "")) != null)
{
// User input from command line / prompt now in "s".
}