SharperHacks.CoreLibs.CommandLineInterface 0.4.0

Prefix Reserved
This package has a SemVer 2.0.0 package version: 0.4.0+built.by.JwD.d5d8d40.
dotnet add package SharperHacks.CoreLibs.CommandLineInterface --version 0.4.0                
NuGet\Install-Package SharperHacks.CoreLibs.CommandLineInterface -Version 0.4.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SharperHacks.CoreLibs.CommandLineInterface" Version="0.4.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SharperHacks.CoreLibs.CommandLineInterface --version 0.4.0                
#r "nuget: SharperHacks.CoreLibs.CommandLineInterface, 0.4.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install SharperHacks.CoreLibs.CommandLineInterface as a Cake Addin
#addin nuget:?package=SharperHacks.CoreLibs.CommandLineInterface&version=0.4.0

// Install SharperHacks.CoreLibs.CommandLineInterface as a Cake Tool
#tool nuget:?package=SharperHacks.CoreLibs.CommandLineInterface&version=0.4.0                

SharperHacks logo

CommandLineParser

SharperHacks.CoreLibs.CommandLineParser

Command line parser.

Licensed under the Apache License, Version 2.0. See LICENSE.

Contact: joseph@sharperhacks.org

Nuget: https://www.nuget.org/packages/SharperHacks.CoreLibs.CommandLineParser

Targets

  • net8.0
  • net9.0

Description

CommandLineParser generates an Arg KVP for every white-space delimited token on the command line or supplied by the caller.

  • Splits each string, of the form -key:value or -key=value, into {Name:key, Value:value} pairs.
  • Tokens of the form value, possitional arguments, are mapped to {Name:#, Value:value} pairs, if there is no ContextDescriptor matching value.
  • Support for verb or non-verb context names. Tokens of the form registeredContextName cause all further tokens to be mapped to that context, up to the next registered context name or occurance of two consecutive hyphens (--).
  • Supports parsing the command line or any supplied array of tokens (useful for interactive systems).
  • Supports response files, @filename.txt will be processed as an EOL delimited array of argument tokens.
    • Supports nested response files.
    • Supports mixed command line args plus one or more response files.
  • Small footprint.
  • Usage/help support.

It is intended for use in simple cases where argument string values are sufficient, or will only be used once, or as a base for more sophisticated options processing of the type needed for more complex applications. An Options & Verbs library that builds on this CommandLineProcessor is a current WIP.

Classes

Arg

The parser generates these from the argument strings using a simple rule set.

ArgContextDb

Tracks option contexts registered by verb and non-verb named contexts.

Args

Responsible for tracking KVP's, their context and rejecting unrecognized keys if matches are required.

CLIExceptions

Thrown when CommandLineParser or related component encounters an error.

CommandLineParser

A static class providing parsing methods. A static Args object parsed from the program command line arguments is the default, but overridable and overwritable behavior.

ContextDescriptor

Context descriptor defines valid verb and non-verb contexts. Allows the parser to distinguish between positional values, verbs and non-verb contexts.

HelpBuilder

Builds a help string from OptionDesccriptor values.

IRunnable

A Run() interface. All verbs must be IRunnable.

OptionBase<T>

Generic option base class.

OptionDescriptor

When used, allows the parser to detect/reject bad arguments.

OptionServices

A collection of static methods used by the various Option bits.

Option<T>

Encapsulates conversion from option string to T.

ResultAccumulator

A result type for IRunable.Run() that allows for simple if x.Run() expressions, optional error messages and logically appending results to each other while preserving failures.

VerbBase

Abstract base class to implement verbs.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.4.0 45 10/23/2024
0.3.1 46 10/13/2024
0.3.0 52 8/17/2024
0.2.0 32 7/26/2024
0.1.0 46 7/14/2024