Giter Club home page Giter Club logo

cmd.net's Introduction

Cmd.Net

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.

NuGet

To install Cmd.Net, run the following command in the Package Manager Console

Install-Package Cmd.Net

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

Example 1

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.

Example 2

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.
...

cmd.net's People

Contributors

yohdeadfall avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.