RealSense.CommandArguments 2.0.1

dotnet add package RealSense.CommandArguments --version 2.0.1                
NuGet\Install-Package RealSense.CommandArguments -Version 2.0.1                
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="RealSense.CommandArguments" Version="2.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add RealSense.CommandArguments --version 2.0.1                
#r "nuget: RealSense.CommandArguments, 2.0.1"                
#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 RealSense.CommandArguments as a Cake Addin
#addin nuget:?package=RealSense.CommandArguments&version=2.0.1

// Install RealSense.CommandArguments as a Cake Tool
#tool nuget:?package=RealSense.CommandArguments&version=2.0.1                

This self contained package simplifies the parsing of command line arguments by defining up front which switches and parameters are defined and whether parameters are required or optional. When defining switches and parameters, you can also provide a description which can be used to generate Usage output content.

How to use

First, declare an instance of RealSense.CommandArguments.ArgHandler and then call DefineSwitch for each switch and DefineParameter for each switch that contains a parameter value after it. Each method is overloaded to accept a single letter (e.g. 'a' or an -a argument), a name (e.g. "alias" for an --alias argument) and a description string (used for usage generation purposes). The DefineParameter also has a "required" boolean parameter to state whether the parameter is required or optional and an optional parameter placeholder name which again is used for usage output.

Switch/Parameter letter/names are case sensitive.

Once you've defined the parameters, call ProcessArguments passing in the string array argument list and an output string for error messages. The method returns true if successful (error message is null) or false if one or more errors were encountered. If errors are encountered, you can output the error message directly to the console.

You can retrieve whether a defined switch included in the command line using GetSwitchValue (overloaded to provide letter or name of parameter). To retrieve a parameter, use GetParameterValue which returns the parameter value or null if not present on the command line.

Example Usage

var argHandler = new RealSense.CommandArguments.ArgHandler();
argHandler.DefineSwitch('f', "If specified, then output contains the full raw XML output, not just a summary.");    // format (summary, full)
argHandler.DefineSwitch('h', "If specified, then an HTML file will be generated that can be used to emulate the calls sequentially.");    // format (summary, full)
argHandler.DefineSwitch('s', "If specified, outputs which files were skipped and for what reason.");    // format (summary, full)
argHandler.DefineSwitch('x', "If specified, removes many of the superflous attributes such as Implemented, AllowRead, AllowWrite, DefaultValue, Type and Vocabulary.");    // format (summary, full)

argHandler.DefineParameter('i', "input", false, "Optional input folder containing the SCORM dump data.  If not set then the current directory is assumed to contain the SCORM dump data instead", "inputfolder");
argHandler.DefineParameter('o', false, "Optional input filename containing the extra.  If not set then a sensible name is generated.", "outputfilename");
argHandler.DefineParameter('U', "user", false, "Optional ID of User to filter by", "userid");
argHandler.DefineParameter('O', "org", false, "Optional ID of Org to filter by", "orgid");
argHandler.DefineParameter('P', "product", false, "Optional ID of Product to filter by", "productid");
argHandler.DefineParameter('S', false, "Optional StartDate filter", "startdate");
argHandler.DefineParameter('E', false, "Optional EndDate  filter", "enddate");

if (!argHandler.ProcessArguments(args, out string error))
{
	Console.Write(error);
	argHandler.Usage();
	return false;
}

FullXmlExtract = argHandler.GetSwitchValue('f');
HtmlOutput = argHandler.GetSwitchValue('h');
OutputSkippedMessages = argHandler.GetSwitchValue('s');
StripSuperflousAttributes = argHandler.GetSwitchValue('x');

var a = argHandler.GetParamValue('U');
if (a != null && int.TryParse(a, out int u) && u > 0)
{
	UserID = u;
	Console.WriteLine($"UserID: {u}");
}
var inputFile = argHandler.GetParamValue('i');

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.1

    • No dependencies.

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
2.0.1 320 3/2/2021