Fecha de publicación: 08/28/08
Hora de publicación: 10:46 AM
Categoría: Colaboradores externos | Comunidad online
Comentarios: RSS 2.0
Por Miguel de Icaza
In an age where the Unix shell is more relevant every passing minute, we need to have proper command line editing tools everywhere.
For a project of mine, this weekend I put together a command-line editing class for .NET shell applications. The Mono.Terminal.LineEdit class can be used by shell applications to get readline-like capabilities without depending on any external C libraries.
To use it, just do:
using Mono.Terminal; LineEditor le = new LineEditor ("MyApp"); while ((s = le.Edit ("prompt> ", "")) != null) Console.WriteLine ("You typed: " + s);
It supports the regular cursor editing, Emacs-like editing commands, history, incremental search in the history as well as history loading and saving.
The code is self-contained, and can be easily reused outside of my project. To use it, you just need to include the getline.cs file in your project. This is built on top of System.Console, so it does not have external library dependencies and will work on both Mono and .NET (finally bringing joy to people using command-line applications that use Console.ReadLine).
It is licensed under the MIT X11 license and the Apache 2.0 license so there are no annoying licensing issues and can be mixed with anything out there.
Miguel de Icaza es un reconocido experto en informática, promotor del software de fuente abierta y es fundador de la compañía Ximian en 1999, la cual fue adquirida por Novell en 2003.
Ultimos comentarios