A powerful and configurable command line interpreter for .NET with no dependencies.
Package Name | Version |
---|---|
Gint.Core | |
Gint.Terminal | |
Gint.Tables | |
Gint.Pipes | |
Gint.Markup |
install-package Gint.Terminal
using Gint;
using Gint.Terminal;
namespace Sample
{
class Program
{
static void Main(string[] args)
{
var runtime = new CommandRuntime();
runtime.CommandRegistry.AddCommand(
commandName: "hello",
helpCallback: o => o.WithForegroundColor().Cyan().Write("help!"),
callback: ctx =>
{
var name = ctx.Scope.GetValueOrDefault(key: "--name", @default: "Gint");
var txt = ctx.Formatter
.WithBackgroundColor().White()
.AndForeground().Black()
.Write($"Hello {name}!");
ctx.Scope.WriteString(txt);
return CommandResult.SuccessfulTask;
})
.AddVariableOption(
argument: "-n",
longArgument: "--name",
helpCallback: o => o.WithForegroundColor().Cyan().Write("Give a name!"),
callback: ctx =>
{
ctx.Scope.Add("--name", ctx.ExecutingCommand.Variable);
return CommandResult.SuccessfulTask;
},
suggestions: v => new Suggestion[] { "Teresa", "Devin", "Michael", "Maria", "George" });
var terminal = new CommandTerminal(runtime);
while (true)
{
terminal.WaitForInput();
}
}
}
}
Diagnostics can be toggled with ctrl+shift+d
or through the TerminalOptions
in the CommandTerminal
constructor.
GintTable
.WithFirstRowAsHeader()
.AddColumn("header1")
.AddColumn("header2")
.NewRow()
.AddColumn("column1")
.AddColumn("column2")
.NewRow()
.AddColumn("column1")
.AddColumn("column2")
.Build()
.RenderToConsole();
For more info on tables, check the wiki.