Is there a .Net library similar to GNU readline?

前端 未结 4 563
被撕碎了的回忆
被撕碎了的回忆 2021-01-05 06:40

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 nec

相关标签:
4条回答
  • 2021-01-05 07:13

    a project that aims to emulate most of the functions of RedLine is Deveel ReadLine, but I have to say that it isn't maintained. Last time I used it it worked very well on both .NET and Mono, although there's a small bug when canceling a line that was automatically folded.

    0 讨论(0)
  • 2021-01-05 07:17

    The only thing I know of is Mono-Readline.

    It provides a .NET interface to the GNU Readline library - it's a bit raw though, only version 0.0.1, and I've only ever seen it run on the Mono runtime.

    You should be careful with licensing too ... AFAIK anything that links the GNU Readline libraries is required to be released under the GPL.

    0 讨论(0)
  • 2021-01-05 07:19

    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".
    }
    
    0 讨论(0)
  • 2021-01-05 07:19

    Old question, but still relevant since it appears in Google search results. It makes sense to mention the following:

    https://github.com/tonerdo/readline is a good option nowadays. Quoting its README:

    ReadLine is a GNU Readline like library built in pure C#. It can serve as a drop in replacement for the inbuilt Console.ReadLine() and brings along with it some of the terminal goodness you get from unix shells, like command history navigation and tab auto completion.

    It is cross platform and runs anywhere .NET is supported, targeting netstandard1.3 means that it can be used with .NET Core as well as the full .NET Framework.

    License

    The project is licensed under the MIT license

    0 讨论(0)
提交回复
热议问题