Clysh 1.3.4

There is a newer version of this package available.
See the version list below for details.
dotnet add package Clysh --version 1.3.4                
NuGet\Install-Package Clysh -Version 1.3.4                
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="Clysh" Version="1.3.4" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Clysh --version 1.3.4                
#r "nuget: Clysh, 1.3.4"                
#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 Clysh as a Cake Addin
#addin nuget:?package=Clysh&version=1.3.4

// Install Clysh as a Cake Tool
#tool nuget:?package=Clysh&version=1.3.4                

Clysh

CLi in Yaml for SHell apps

Create your own CLI on .NET 6+ with simple steps.

Release Notes

  • 1.0.2 - Initial release
  • 1.0.3 - Parameters creation using builder pattern
  • 1.0.4 - XML docs for all public classes
  • 1.0.5 - More production safety validations
  • 1.0.6 - Simplify option check id
  • 1.0.7 - Order parameter by property and introduce filled property to parameter model
  • 1.0.8 - BugFix: Lastcommand executed flag fix
  • 1.0.9 - Some improvements to order parameters and increase max description to 100 chars
  • 1.1.0 - BugFix: Parameter filled order
  • 1.2.0 - Make action by command path
  • 1.3.1 - BugFix: Debug mode
  • 1.3.4 - Data transfer between comands and description breakline after each 50 chars

What is?

Clysh is a library to create a .NET Command Line Interface (CLI). The main goal is to create your own CLI with only business code.

Features

Clysh has some features to facilitate the process of create a CLI.

  • You can write your own CLI as an YAML or JSON file. The file is parsed at runtime.
  • Easy to make a command tree. You can nest commands to run in a specific order;
  • The commands can have custom options with your own shortcuts;
  • The options can have required and/or optional parameter to some user data input.
  • You can group options like a radio button.

Getting Started

To use Clysh you need to install the package from NuGet.

dotnet add package clysh

Then, to start create a clidata.yml with the content below:

Title: MyCLI with only test command
Version: 1.0
Commands:
  - Id: mycli
    Description: My own CLI
    Groups:
      - foo
    Options:
      - Description: Test option
        Id: test
        Shortcut: T
        Parameters:
          - Id: value
            Required: true
            MinLength: 1
            MaxLength: 15
        Group: foo
      - Description: Test option
        Id: dummy
        Shortcut: d
        Parameters:
          - Id: value
            Required: true
            MinLength: 1
            MaxLength: 15
        Group: foo
    Root: true
    SubCommands:
      - mychild
  - Id: mychild
    Description: My child

To use this create a new Console Application, then in your Program.cs write this:

using Clysh.Core;

var setup = new ClyshSetup("clidata.yml");

setup.MakeAction("mycli", (_, options, view) =>
{
    view.Print(options["test"].Selected ? "mycli with test option" : "mycli without test option");

    if (options["test"].Selected)
    {
        var option = options["test"];

        var data = option.Parameters["value"].Data;

        view.Print(data);
    }
});

var cli = new ClyshService(setup, true);

cli.Execute(args);

Run the console and you will see the magic. If you need some help, pass the argument --help to your app.

The expected output:

mycli without test option

With --help argument

MyCLI with only test command. Version: 1.0

Usage: mycli [options] [commands]

My own CLI

[options]:

   Shortcut   Option       Group          Description                                            Parameters: (R)equired | (O)ptional = Length

  -h        --help                        Show help on screen
  -d        --dummy        foo            Test option                                            [0:<value:R>]: 1
  -T        --test         foo            Test option                                            [0:<value:R>]: 1

[commands]:

   mychild                                My child  

Note: The project of example app is available on ./Samples/Clysh.Sample folder

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 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. 
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
2.6.3 272 3/17/2023
2.6.2 230 3/17/2023
2.6.1 235 3/17/2023
2.6.0 223 3/16/2023
2.5.0 235 3/9/2023
2.4.0 235 3/7/2023
2.3.1 207 3/6/2023
2.3.0 224 3/5/2023
2.2.0 256 3/5/2023 2.2.0 is deprecated because it is no longer maintained.
2.1.0 292 2/7/2023 2.1.0 is deprecated because it is no longer maintained.
2.0.1 327 2/3/2023 2.0.1 is deprecated because it is no longer maintained.
2.0.0 305 2/3/2023 2.0.0 is deprecated because it is no longer maintained.
1.4.1 330 1/14/2023
1.4.0 421 8/16/2022
1.3.6 475 8/12/2022 1.3.6 is deprecated because it is no longer maintained.
1.3.5 482 8/8/2022 1.3.5 is deprecated because it is no longer maintained.
1.3.4 440 8/7/2022 1.3.4 is deprecated because it is no longer maintained.
1.3.3 466 8/2/2022 1.3.3 is deprecated because it is no longer maintained.
1.3.2 457 8/2/2022 1.3.2 is deprecated because it is no longer maintained.
1.3.1 478 8/2/2022 1.3.1 is deprecated because it is no longer maintained.
1.3.0 481 7/24/2022 1.3.0 is deprecated because it is no longer maintained.
1.2.0 457 7/21/2022 1.2.0 is deprecated because it is no longer maintained.
1.1.0 474 7/18/2022 1.1.0 is deprecated because it is no longer maintained.
1.0.9 478 7/6/2022 1.0.9 is deprecated because it is no longer maintained.
1.0.8 515 6/25/2022 1.0.8 is deprecated because it is no longer maintained.
1.0.7 498 6/25/2022 1.0.7 is deprecated because it is no longer maintained.
1.0.6 527 6/22/2022 1.0.6 is deprecated because it is no longer maintained.
1.0.5 459 6/22/2022 1.0.5 is deprecated because it is no longer maintained.
1.0.4 502 6/11/2022 1.0.4 is deprecated because it is no longer maintained.
1.0.3 495 6/11/2022 1.0.3 is deprecated because it is no longer maintained.
1.0.2 478 6/11/2022 1.0.2 is deprecated because it is no longer maintained.