IgniteCLI 1.0.0

The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package IgniteCLI --version 1.0.0
NuGet\Install-Package IgniteCLI -Version 1.0.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="IgniteCLI" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add IgniteCLI --version 1.0.0
#r "nuget: IgniteCLI, 1.0.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 IgniteCLI as a Cake Addin
#addin nuget:?package=IgniteCLI&version=1.0.0

// Install IgniteCLI as a Cake Tool
#tool nuget:?package=IgniteCLI&version=1.0.0

Ignite CLI

Ignite is a library for creating CLI applications in .NET Core

Overview

Ignite helps you quickly create and augment your .NET Core Console App projects. When Ignite is given a list of Commands, set up is complete. Ignite will parse and convert user input automatically then trigger the given functions with the appropriate arguments.

Getting Started

  1. Create a new .NET Console App (.NET Core 2.0) project
  2. Follow Installation
  3. Declare and define a CommandList
  4. Run CLI.Start(MyCommandList) in the static void Main(string[] args) method that's provided with Console Apps

Installation

To install Ignite simply find the package in the Nuget package browser or run

Install-Package IgniteCLI

NOTE: .NET Core 2.0 is required in order to use Ignite.

Usage

API

  • CLI.Start(CommandList commands)
    • This method is what initializes Ignite with the given CommandList
Printing

Ignite provides multiple methods for output, including the ability to customize color

  • CLI.Help()
    • Help prints out the CommandList in an easy-to-read format
  • CLI.Break()
    • Outputs a line of hypens to a new line in the Console
  • CLI.Out(string s = "")
    • Outputs s to a new line in the Console
  • CLI.Out(string s, ConsoleColor fore, ConsoleColor back = ConsoleColor.Black)
    • Outputs s to a new line in the Console with the given foreground and background color
Dynamic

Ignite lets you simulate user input for programmatic command execution

  • CLI.Run(string command, params string[] args)
    • Runs the command with the provided args as if they were typed into the Console by a user
    • Example: CLI.Run("add", "a 10", "b 5")
    • Example: CLI.Run("add", new string[2] {"a 10", "b 5"})
  • CLI.Run(params string[] input)
    • Extracts the first element in the array and calls the above CLI.Run() passing that in as the command and the rest as the args
    • Example: CLI.Run("add", "a 10", "b 5")
    • Example: CLI.Run(new string[3] {"add", "a 10", "b 5"})
Parsing Arguments

During command functions, Ignite provides quick methods to automatically parse and convert arguments

  • CLI.String(Dictionary<string, string> d, string key)
    • Parses the value from the Dictionary<string, string> as a String
  • CLI.Int(Dictionary<string, string> d, string key)
    • Parses the value from the Dictionary<string, string> as a Int
  • CLI.Bool(Dictionary<string, string> d, string key)
    • Parses the value from the Dictionary<string, string> as a Bool
    • "true" and "false" are evaluated appropriately
    • When no value is given, it is evaluated as true

Commands

Structure

public static CommandList Commands = new CommandList
{
    new Command
    {
        Name = "mycommand",
        Description = "Executes My Command with the given arguments",
        Args = new CommandArgs
        {
            new CommandArg
            {
                Tag = "string-in",
                InputFormat = "Informs user of the value to provide for 'string-in'",
                Description = "(str) This is my first CommandArg named 'string-in'",
                //Required = true by default
            },
        },
        Function = args =>
        {
            string input = CLI.String(args, "string-in");
            if(String.IsNullOrEmpty(input)) CLI.Help(); //No input given, show help
            else
            {
                CLI.Out(MyCommand(input));
            }
        }
    },
}

Example

new Command
{
    Name = "add",
    Description = "Add two numbers together",
    Args = new CommandArgs
    {
        new CommandArg
        {
            Tag = "a",
            InputFormat = "first number",
            Description = "(int) The first number in the equation",
        },
        new CommandArg
        {
            Tag = "b",
            InputFormat = "second number",
            Description = "(int) The second number in the equation",
        }
    },
    Function = args =>
    {
        int a = CLI.Int(args, "a");
        int b = CLI.Int(args, "b");
        CLI.Out($"{a} + {b} = {a + b}", ConsoleColor.Green);
    }
},

Expected Output

Output

Generated Help

Help


Sample Program

This is an example of a simple CLI made with Ignite.

using System;
using IgniteCLI;

namespace IgniteExample
{
    class Program
    {
        static CommandList commands = new CommandList
        {
            new Command
            {
                Name = "hello",
                Description = "Says hello",
                Args = new CommandArgs
                {
                    new CommandArg
                    {
                        Tag = "name",
                        InputFormat = "user name",
                        Description = "(string) The name used when saying hello",
                        Required = false,
                    }
                },
                Function = args =>
                {
                    string name = CLI.String(args, "name");
                    CLI.Out($"Hello, {(String.IsNullOrEmpty(name) ? "World" : name)}!");
                }
            },
        };
        static void Main(string[] args)
        {
            CLI.Start(commands);
        }
    }
}
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 netcoreapp2.0 is compatible.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETCoreApp 2.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