New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

Niche.CommandLineProcessor

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

Niche.CommandLineProcessor

Convention based argument handling for console applications.

Source
nugetNuGet
Version
3.1.4
Version published
Maintainers
1
Created
Source

Niche.CommandLine Quick Reference

A convention based argument handler for writing console applications.

Program.cs

Eliminate most of the boilerplate in Program.cs:

static int Main(string[] args)
{
    using(var processor = new CommandLineProcessor(args))
    {
        processor.WhenHelpRequired(ShowHelp)
            .WhenErrors(ShowErrors);

        return processor.Parse<ProgramOptions>()
            .Execute(Run);
    }
}

For a complete working demo, see https://github.com/theunrepentantgeek/Niche.CommandLineProcessor/blob/master/src/Niche.CommandLine.Demo/Program.cs

Options

To configure the options available, follow the following conventions:

// A switch
// (void method with no parameters)
// --verbose
// -v
[Description("Verbose output")]
public void Verbose() ...

See https://github.com/theunrepentantgeek/Niche.CommandLineProcessor/wiki/Conventions#switches for more.

// A parameter with a single value
// (void method with single parameter)
// --output-file
// -of
[Description("Destination file for output")]
public void OutputFile(string file) ...

See https://github.com/theunrepentantgeek/Niche.CommandLineProcessor/wiki/Conventions#parameters for more.

// A parameter with multiple values
// (void method with IEnumerable parameter)
// --input-file
// -if
[Description("Input files to consume")]
public void InputFile(IEnumerable<string> files)
// A distinct program mode
// (method with no parameter returning a new options instance)
// render
[Description("Render documents")]
public RenderOptions Render()
{
    return new RenderOptions();
}

See https://github.com/theunrepentantgeek/Niche.CommandLineProcessor/wiki/Mode-Support for more.

Keywords

command

FAQs

Package last updated on 20 Jan 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts