Cmd.Net is a .Net library for building command-line applications with supporting netsh-like contexts and automatic help generation. It provides a convenient and laconic API for working with the command line. The library allows you to forget about parser code writing and to concentrate on the application logic.

Cmd.Net 1.3
The most recent version is Cmd.Net 1.3. You can download it here or from GitHub.

Features
  1. One command — one method. No if-else or switch-case needed to determine what shall be done.
  2. Running a single command or all commands from user input until the application is over.
  3. Argument parsing customization.
  4. Creating netsh-like contexts.
  5. Automatic help generation.

Compatibility
.Net Framework 3.5 and later

Examples
A command with a description for the help generation and the id parameter custom parsing. The store parameter is optional and its default value is null.
[Verb("copy")]
[Description("Creates a copy of the specified boot entry.")
public static void CopyBootEntry(
	[Output] TextWriter output,
	[Argument, Descritpion("Specifies the identifier of the entry to be copied."), TypeConverter(typeof(BootEntryGuidConverter))] Guid id,
	[Argument("store"), Descritpion("Specifies the description to be applied to the new entry.")] string store = null,
	[Argument("d"), Descritpion("Specifies the store to be used. If this option is not specified, the system store is used.")] string description
	)
{
}
Creates a copy of the specified boot entry.
copy id /d:value [/store:value]

  id     Specifies the identifier of the entry to be copied.
  /d     Specifies the description to be applied to the new entry.
  /store Specifies the store to be used. If this option is not specified, the system store is used.

Context with child commands and contexts.
CommandContext rootContext = new CommandContext(
	"netsh",
	new Command(new Action(AddHelper)),
	new CommandContext(
		"advfirewall",
		"Changes to the 'netsh advfirewall' context.",
		new CommandContext(
			"consec",
			"Changes to the 'netsh advfirewall consec' context."
			/* ...*/
			),
		/* ...*/
		),
	/* ...*/
	);
netsh>/?
add          Adds a configuration entry to a list of entries.
advfirewall  Changes to the 'netsh advfirewall' context.
...

netsh>advfirewall /?
consec       Changes to the `netsh advfirewall consec' context.
...

Last edited Feb 3, 2015 at 10:36 AM by YohDeadfall, version 6