Monarch 3.0.93

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

// Install Monarch as a Cake Tool
#tool nuget:?package=Monarch&version=3.0.93                

Monarch

.NET Publish Coverage Status

Monarch is a command line parser/task runner.

Basic Usage

In order to use the system, you need to register it with your ServiceCollection:

serviceCollection.AddCanisterModules();
				

This is required prior to using the Monarch class for the first time. Once it is wired up, you can use the CommandRunner class:

var Instance = new CommandRunner();
return Instance.Run(args);

The CommandRunner class has a Run method which parses the args passed in and runs the appropriate command. The library has help and version commands built in to the system, however to create your own commands you need to create a command and also an input class:

public class TestCommand : CommandBaseClass<TestInput>
{
    public override string[] Aliases => new string[] { "Test" };

    public override string Description => "Test command";

    public override string Name => "Test Command";

    protected override async Task<int> Run(TestInput input)
    {
        await Task.CompletedTask;
        Console.WriteLine(input.Value1);
        Console.WriteLine(input.Value2);
        Console.WriteLine(input.Value3.ToString(x => x));
        return 0;
    }
}

public class TestInput
{
    [Display(Description = "Value 1 Property")]
    public int Value1 { get; set; }

    [Display(Description = "Value 2 Property")]
    public string Value2 { get; set; }

    [Display(Description = "Value 3 Property")]
    [MaxLength(3)]
    public List<string> Value3 { get; set; }
}

The command above inherits from the CommandBaseClass and defines the input that it expects. In this case TestInput. TestInput is how the command line arguments should be parsed by the system. The commands must define the aliases, description, and name for the command. The TestInput then defines properties and uses the DisplayAttribute from the System.ComponentModel.DataAnnotations namespace to define information. Also any data annotations defining max length, required, etc. are used to validate the input.

Options

By default the system does not require you to set options. However you can specify some options found within the system including command prefix, flag prefix, and indentation amount. In order to override what is in the system just create a class that inherits from IOptions:

public class DefaultOptions : IOptions
{
    /// <summary>
    /// Gets the command prefix.
    /// </summary>
    /// <value>The command prefix.</value>
    public string CommandPrefix { get; } = "";

    /// <summary>
    /// Gets the flag prefix.
    /// </summary>
    /// <value>The flag prefix.</value>
    public string FlagPrefix { get; } = "-";

    /// <summary>
    /// Gets the indent amount.
    /// </summary>
    /// <value>The indent amount.</value>
    public int IndentAmount { get; } = 4;
}
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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Monarch:

Package Downloads
TaskMaster

TaskMaster is a simple library used to manage sets of fire and forget tasks that need to run after specific dates/times.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
4.0.0 79 11/24/2024
3.0.116 139 11/13/2024
3.0.115 94 11/12/2024
3.0.114 105 11/11/2024
3.0.113 106 11/8/2024
3.0.112 102 11/6/2024
3.0.111 134 11/4/2024
3.0.110 121 10/31/2024
3.0.109 114 10/30/2024
3.0.108 74 10/29/2024
3.0.107 106 10/29/2024
3.0.106 219 10/11/2024
3.0.105 117 10/10/2024
3.0.104 393 9/9/2024
3.0.103 190 8/29/2024
3.0.102 135 8/27/2024
3.0.101 135 8/26/2024
3.0.100 197 8/22/2024
3.0.99 152 8/21/2024
3.0.98 160 8/20/2024
3.0.97 188 8/15/2024
3.0.96 179 8/5/2024
3.0.95 159 7/25/2024
3.0.94 166 7/11/2024
3.0.93 238 6/27/2024
3.0.92 138 6/26/2024
3.0.91 167 6/21/2024
3.0.90 154 6/19/2024
3.0.89 155 6/18/2024
3.0.88 140 6/17/2024
3.0.87 148 6/14/2024
3.0.86 145 6/13/2024
3.0.85 190 5/31/2024
3.0.84 198 5/30/2024
3.0.83 164 5/17/2024
3.0.82 123 5/16/2024
3.0.81 179 5/8/2024
3.0.80 159 5/7/2024
3.0.79 161 5/6/2024
3.0.78 152 5/3/2024
3.0.77 105 5/2/2024
3.0.76 116 5/1/2024
3.0.75 144 4/30/2024
3.0.74 151 4/30/2024
3.0.73 225 4/14/2024
3.0.72 108 4/12/2024
3.0.71 146 4/11/2024
3.0.70 196 4/1/2024
3.0.69 150 3/29/2024
3.0.68 208 3/18/2024
3.0.67 153 3/15/2024
3.0.66 146 3/14/2024
3.0.65 172 3/11/2024
3.0.64 169 3/8/2024
3.0.63 152 3/7/2024
3.0.62 149 3/6/2024
3.0.61 134 3/5/2024
3.0.60 117 3/4/2024
3.0.59 268 2/29/2024
3.0.58 150 2/28/2024
3.0.57 147 2/26/2024
3.0.56 179 2/23/2024
3.0.55 140 2/22/2024
3.0.54 119 2/21/2024
3.0.53 269 2/15/2024
3.0.52 172 2/12/2024
3.0.51 181 2/8/2024
3.0.50 147 2/7/2024
3.0.49 160 2/6/2024
3.0.48 193 2/1/2024
3.0.47 251 1/24/2024
3.0.46 125 1/23/2024
3.0.45 250 1/11/2024
3.0.44 321 12/19/2023
3.0.43 177 12/14/2023
3.0.42 147 12/13/2023
3.0.41 304 11/24/2023
3.0.40 204 11/21/2023
3.0.39 142 11/20/2023
3.0.38 171 11/17/2023
3.0.37 185 11/16/2023
3.0.36 158 11/15/2023
3.0.35 251 11/9/2023
3.0.34 193 11/7/2023
3.0.33 153 11/6/2023
3.0.32 242 11/1/2023
3.0.31 160 10/31/2023
3.0.30 167 10/30/2023
3.0.29 200 10/26/2023
3.0.28 213 10/12/2023
3.0.27 258 9/26/2023
3.0.26 168 9/20/2023
3.0.25 172 9/19/2023
3.0.24 165 9/18/2023
3.0.23 206 9/14/2023
3.0.22 174 9/13/2023
3.0.21 177 9/12/2023
3.0.20 180 9/11/2023
3.0.19 217 9/7/2023
3.0.18 175 9/6/2023
3.0.17 168 9/5/2023
3.0.16 177 9/4/2023
3.0.15 194 9/1/2023
3.0.14 178 8/31/2023
3.0.13 180 8/30/2023
3.0.12 191 8/29/2023
3.0.11 193 8/28/2023
3.0.10 234 8/23/2023
3.0.9 231 8/18/2023
3.0.8 225 8/16/2023
3.0.7 206 8/9/2023
3.0.6 206 8/8/2023
3.0.5 142 8/8/2023
3.0.4 217 8/7/2023
3.0.3 224 8/4/2023
3.0.2 292 7/26/2023
3.0.1 296 7/14/2023
3.0.0 418 12/12/2022
2.0.16 443 6/10/2022
2.0.14 305 1/11/2022
2.0.13 1,327 1/11/2022
2.0.12 778 1/10/2022
2.0.10 648 6/21/2021
2.0.8 357 6/21/2021
2.0.6 687 1/6/2021
2.0.5 1,038 9/13/2020
2.0.4 743 3/29/2020
2.0.3 1,040 3/25/2020
2.0.2 792 3/3/2020
2.0.1 1,471 12/31/2019
2.0.0 1,000 12/23/2019
1.0.7 1,111 8/31/2018
1.0.6 761 8/31/2018
1.0.5 768 8/31/2018