cclip.net 0.0.1

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

// Install cclip.net as a Cake Tool
#tool nuget:?package=cclip.net&version=0.0.1

cclip.net Documentation

Introduction

The cclip.net (C# Command Line Interface Parser for .NET) library is a lightweight command-line argument parsing tool for .NET applications. It simplifies the process of parsing command-line arguments and provides an easy-to-use interface for defining and handling command-line options.

This documentation will guide you through using the cclip.net library to define and parse command-line arguments in your .NET application.

Installation

Before you can start using the cclip.net library, you need to include it in your .NET project. You can do this by adding a reference to the Chase ccliparser.dll assembly in your project.

Using NuGet Package Manager

You can also install the cclip.net library using NuGet Package Manager:

Install-Package cclip.net

Usage

Initializing the OptionsManager

To get started with cclip.net, you first need to create an OptionsManager object to define the command-line options that your application will accept.

OptionsManager manager = new OptionsManager("cclip.net");

Adding Command-Line Options

You can add command-line options to the OptionsManager using the Add method. Each option is defined by an Option object, which specifies its short name, long name, whether it has an argument, whether it is required, and a description.

manager.Add(new Option()
{
    ShortName = "i",
    LongName = "input",
    HasArgument = true,
    Required = true,
    Description = "The input file."
});

manager.Add(new Option()
{
    ShortName = "o",
    LongName = "output",
    HasArgument = true,
    Required = true,
    Description = "The output file."
});

manager.Add(new Option()
{
    ShortName = "c",
    LongName = "continue",
    HasArgument = false,
    Required = false,
    Description = "Continue the application."
});

manager.Add(new Option()
{
    ShortName = "cc",
    LongName = "connections",
    HasArgument = true,
    Required = false,
    Description = "The number of connections of the application."
});

Parsing Command-Line Arguments

Once you've defined your command-line options, you can use the OptionsParser to parse the command-line arguments passed to your application.

OptionsParser parser = manager.Parse(Environment.GetCommandLineArgs());

Checking for Option Presence

You can check if a specific option is present in the parsed arguments using the IsPresent method of the OptionsParser. It also allows you to retrieve the value of an option with an argument.

if (parser.IsPresent("i", out string input))
{
    Console.WriteLine($"Input file is {input}");
}

if (parser.IsPresent("o", out string output))
{
    Console.WriteLine($"Output file is {output}");
}

if (parser.IsPresent("c"))
{
    Console.WriteLine("Continue is enabled");
}
else
{
    Console.WriteLine("Continue is disabled");
}

if (parser.IsPresent("cc", out string connections))
{
    Console.WriteLine($"Connections set to {connections}");
}
else
{
    Console.WriteLine($"Connections set to 6");
}

Example

Here's an example of how you can use cclip.net in your .NET application:

using cclip;

internal class Program
{
    private static void Main(string[] args)
    {
        OptionsManager manager = new("application name");
        manager.Add(new() { ShortName = "v", LongName = "version", HasArgument = false, Required = false, Description = "displays the version" });
        manager.Add(new() { ShortName = "p", LongName = "print", HasArgument = true, Required = false, Description = "prints the text inputted" });
        manager.Add(new() { ShortName = "i", LongName = "input", HasArgument = true, Required = true, Description = "input path" });

        OptionsParser parser = manager.Parse(args);

        if (parser.IsPresent("version"))
        {
            Console.WriteLine("1.0.0");
        }
        else if (parser.IsPresent("print", out string print))
        {
            Console.WriteLine(print);
        }
        else if (parser.IsPresent("input", out string input))
        {
            Console.WriteLine(input);
        }
    }
}

Auto Help generation

there is no need to to add a help option you can type -h -? or --help to display the help image

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.0

    • No dependencies.
  • net7.0

    • 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.0.1 249 10/30/2023