SGrottel.yaclap 0.3.0

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

// Install SGrottel.yaclap as a Cake Tool
#tool nuget:?package=SGrottel.yaclap&version=0.3.0                

yaclap

Yet Another Command Line Argument Parser, for c++, as single-header-only library, natively supporting wchar_t, with a minimal feature set, e.g. without advanced type conversion and validation, just because...

Version: 0.3.0 Git Hash: 45ccc091b1f6c0a8725b9e92f72315f63ee43d59

Additional information is available on the project webseit: https://github.com/sgrottel/yaclap

Concepts

This command line parser is inspired by the POSIX standard and especially the System.CommandLine CSharp Library.

Features

  • Commands also called 'verbs', switching to specific sets of Options, Arguments, and Commands supported
  • Options are optionally named input, followed by a Argument value
  • Alias names for Options, Switches, and Commands
  • Arguments are values, either following an Option, or being identified by it's position in the stream of arguments, which are not otherwise matched. Arguments have names for the readability of the generated documentation only.
  • Switches are special Options without an explicit Argument
  • -- the double-dash token stops the parsing and will return all following arguments as unmatched
  • Automatic --help documentation generation is supported
  • Option-argument delimiters are supported: (space), =, and :
  • Supports case-sensitive and case-insensitive matching of names of Options and Switches
  • Supports basic value conversion of Option values and Argument values to basic types: long integer numbers, double-precision floating-point numbers, and boolean values

Usage Example

You define the command line argument syntax for your application via objects of the types Command, Option, Switch, and Argument, added to either Command objects or your main Parser object.

Option inputOption{
    {_T("--input"), StringCompare::CaseInsensitive},
    _T("file"),
    _T("An input file")};
Switch verboseSwitch{
    {_T("--verbose"), StringCompare::CaseInsensitive},
    _T("Verbosity switch")};
Command commandA{
    {_T("CommandA"), StringCompare::CaseInsensitive},
    _T("Command A")};
commandA
    .Add(inputOption);
parser
    .Add(commandA)
    .Add(verboseSwitch);

The parser result can then be easily assigned your variables:

Parser::Result res = parser.Parse(argc, argv);

auto andValue = res.GetArgument(andArgument);
if (andValue)
{
    m_andArg = andValue;
}

m_boolValue = res.GetOptionValue(boolValueOption, Parser::Result::ErrorIfMultiple).AsBool().value_or(false);

See the online documentation and online example file src/cmdargs.cpp for more information.

License

This library is freely available as open source under the MIT License:

MIT License

Copyright (c) 2024 Sebastian Grottel

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

If you are using this library in an open-source software, the above copyright notice must not be removed from the yaclap.hpp file. But you do not need to reproduce the copyright notice in the compiled binary or accompanying documentation.

Product Compatible and additional computed target framework versions.
native native is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has 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
0.3.0 96 12/4/2024