Coder Social home page Coder Social logo

luckyone-cc / commandcenter Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 367 KB

The "CommandCenter" library enables simple implementation and management of commands in applications. Developers can use this library to register, describe and execute commands. Command line parsing and utilities for .NET

License: MIT License

C# 100.00%
cli cli-tool command command-line command-line-tool command-system command-tool commandhandler csharp library

commandcenter's Introduction

CommandCenter Library

The CommandRegistry library simplifies the implementation and management of commands in applications. This library allows developers to register, describe, and execute commands easily. The registry approach facilitates the integration of new commands, enhancing the flexibility and extensibility of applications.

Features

  • Command Registration: Easily register commands with descriptions and optional parameters.
  • Centralized Command Execution: Provides a central interface for executing commands, promoting code consistency and maintainability.
  • Flexibility: Supports dynamic addition and removal of commands, making it suitable for evolving applications.
  • User Interaction: Ideal for applications requiring a command-line interface or similar interactive control.

Getting Started

Installation

You can download the CommandCenter library from releases, NuGet or build it yourself:

NuGet\Install-Package CommandCenter

Usage

1. Create a commandHandler:

  var commandHandler = new CommandHandler();

2. Add Commands:

  commandHandler.AddCommand(new CommandBuilder("example")
      .SetDescription("Example command")
      .SetAction(parameters =>
      {
          // Command logic here
          Console.WriteLine("Executing the example command!");
      })
      .Build());

3. Add Parameters to command:

    commandHandler.AddCommand(new CommandBuilder("dosome")
        .SetDescription("Description")
        .WithParameter("n", "Description for n")
        .SetAction(parameters =>
        {
            string n = parameters.GetParameterValue("n");

            if (n != null)
            {
                DoSomething(n);
            }
            else
            {
                Console.WriteLine("Missing parameters for the 'n' command. Use -n");
            }
        })
        .Build());

4. Process Commands:

  while (true)
  {
      Console.Write("Enter a command: ");
      string input = Console.ReadLine();
      commandHandler.ProcessCommand(input);
  }

commandcenter's People

Contributors

luckyone-cc avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.