GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - MangoTwo2/commandline: Command Line Parser Library

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

269 Commits
269 Commits

Folders and files

NameName
Last commit message
Last commit date
.nuget
.nuget
 
 
art
art
 
 
doc
doc
 
 
nuget
nuget
 
 
packages
packages
 
 
src
src
 
 
.gitignore
.gitignore
 
 
CommandLine.5.1.ReSharper
CommandLine.5.1.ReSharper
 
 
CommandLine.sln
CommandLine.sln
 
 
CommandLine.sln.DotSettings.user
CommandLine.sln.DotSettings.user
 
 
CommandLine.snk
CommandLine.snk
 
 
CommandLine4.sln.DotSettings.user
CommandLine4.sln.DotSettings.user
 
 
README.md
README.md
 
 

Repository files navigation

Command Line Parser Library 2.0.0.0 pre-release for CLR.

The Command Line Parser Library offers to CLR applications a clean and concise API for manipulating command line arguments and related tasks defining switches, options and verb commands. It allows you to display an help screen with an high degree of customization and a simple way to report syntax errors to the end user. Everything that is boring and repetitive to be programmed stands up on library shoulders, letting developers concentrate on core logic. This library provides hassle free command line parsing with a constantly updated API since 2005.

Compatibility:

  • .NET Framework 3.5+
  • Mono 2.1+ Profile

Current Release:

  • This is a pre-release, for documentation please read appropriate wiki section.

At glance:

  • One line parsing using default singleton: CommandLine.Parser.Default.ParseArguments(...).
  • One line help screen generator: HelpText.AutoBuild(...).
  • Map command line arguments to sequences (IEnumerable<T>), enum or standard scalar types.
  • Plug-In friendly architecture as explained here.
  • Define verb commands as git commit -a.
  • Most of features applies with a CoC philosophy.
  • F# specific API (work in progress).

To install:

  • NuGet way (latest stable): Install-Package CommandLineParser
  • NuGet way (latest version): Install-Package CommandLineParser -pre
  • XCOPY way: cp -r CommandLine/src/libcmdline To/Your/Project/Dir

To build:

MonoDevelop or Visual Studio

Public API:

Latest changes are recorded from Version 1.9.4.91, please refer to this document.

Notes:

The project is and well suited to be included in your application. If you don't merge it to your project tree, you must reference CommandLine.dll and import CommandLine and CommandLine.Text namespaces (or install via NuGet). The help text builder and its support types lives in CommandLine.Text namespace that is loosely coupled with the parser. However is good to know that HelpText class will avoid a lot of repetitive coding.

Define a class to receive parsed values:

class Options {
  [Option('r', "read", Required = true,
    HelpText = "Input files to be processed.")]
  public IEnumerable<string> InputFiles { get; set; }
    
  // omitting long name, default --verbose
  [Option(DefaultValue = true,
    HelpText = "Prints all messages to standard output.")]
  public bool Verbose { get; set; }

  [Value(0)]
  public int Offset { get; set;}
  }
}

Consume them:

static void Main(string[] args) {
  var result = CommandLine.Parser.Default.ParseArguments<Options>(args);
  if (!result.Errors.Any()) {
    // Values are available here
    if (result.Value.Verbose) Console.WriteLine("Filenames: {0}", string.Join(",", result.Value.InputFiles.ToArray()));
  }
}

Acknowledgements:

Thanks to JetBrains for providing an open source license for ReSharper.

Main Contributors (alphabetical order):

  • Alexander Fast (@mizipzor)
  • Dan Nemec (@nemec)
  • Kevin Moore (@gimmemoore)
  • Steven Evans

Resources for newcomers:

  • CodePlex
  • Quickstart
  • Wiki
  • GNU getopt

Latest Changes:

  • Implemented issue #31 (double dash), thanks also to PR #77 by Tom Glastonbury (@tg73).

Contacts:

Giacomo Stelluti Scala

  • gsscoder AT gmail DOT com
  • Blog
  • Twitter

About

Command Line Parser Library

Resources

Readme
Activity

Stars

0 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.