Skip to content
Tim Abell edited this page May 14, 2015 · 65 revisions

Warning

2015-01-25: The original developer (who has sole commit access) has put this project on hold indefinitely to focus on other things.

Alternative Projects

@cosmo0 is maintaining a fork of this project so that any bugs that are found may be fixed. Although he does not actively develop the project, he will accept pull requests.

The clipr project is an alternative command line parser in the style of Python's ArgParse library.

ManyConsole is an extension to NDesk.Options for writing console applications with multiple commands.

Are there others? Add them here.

A quick nuget search shows rather a lot https://www.nuget.org/packages?q=command+line+argument+parser


Home

The Command Line Parser Library offers to CLR applications a clean and concise API for manipulating command line arguments and related tasks.

A lot is supplied out of the box, but almost everything is customizable when necessary.

  • It allows you to display an help screen with an high degree of customization and a simple way to report syntax errors to the user.
  • Everything that is boring and repetitive to be programmed stands up on library shoulders, letting you concentrate yourself on core logic.

This library provides hassle free command line parsing with a constantly updated API since 2005.

This wiki refers to latest stables, if a beta version is available in github master branch please refer to Latest Beta.

At glance

  • Library available via NuGet:
  • Latest Stable: Install-Package CommandLineParser.
  • Latest Beta (not currently avaible): Install-Package CommandLineParser -Pre.
  • One line parsing using default singleton: CommandLine.Parser.Default.ParseArguments(...).

Overview

The command line input, read from the standard entry point as string array, is then pushed in an instance of a custom type decorated with library attributes (see fake objects from test project as reference). You just create this class with one field for each option value you want to make persistent (and a special field for non-option values). Rules about command line options are engraved in your custom type from library attributes.

Consuming The Code

  • Source Inclusion. The project is entirely written in C# and is also thought to be included in another (C#) project.
  • DLL Referencing. Anyway you can reference the library as binary DLL file, consuming it from any .NET language.

Benefits

  1. Remove from each application the code specific for command line parsing.
  2. Promote code reuse through a consistent, clear and easy to use API.
  3. The API is lightweight, has no external dependencies and is easy to integrate within an application.
  4. The project and its documentation are continuously updated and extended.
  5. It has been used for years in closed and open source projects.
  6. This project has also grown through the interaction of enthusiastic users and from constructive criticism.
  7. Comments and various types of communication are taken seriously by the author.
  8. Warp speed start with templates.