Coder Social home page Coder Social logo

promptcli's Introduction

PromptCLI

Nuget Azure DevOps builds Coverage

PromptCLI is inspired from inquirer.js and enquirer.js. It is a interactive command line interface library.

Basics

Usage

public class TestClass
{
    [Input("Project Name ?")]
    public string ProjectName { get; set; }

    [Select(typeof(string), "License Type ?", "MIT", "GNU", "Apache")]
    public string License { get; set; }

    [Checkbox(typeof(int), "Level ?", 1, 2, 3, 4)]
    public IEnumerable<int> Level { get; set; }

    [Input("Briefly explain ?")]
    public string Description { get; set; }
}

static void Main(string[] args)
{
    var prompt = new Prompt();

    var obj = prompt.Run<TestClass>(obj);
}

Without POCO class (Callback Action)

You can handle a callback action after each step

var project = new Project();

var prompt = new Prompt();
prompt.Add(new InputComponent("Project Name", "Project1"))
        .Callback(i => project.ProjectName = i)
    .Add(new SelectComponent<string>("License Type", new List<string>() { "MIT", "Apache", "GNU" } ))
        .Callback(i => project.License = i)
    .Add(new CheckboxComponent<string>("Features", new List<string>() { "Linter", "Router", "Other" }))
        .Callback(i => project.Features = i)
    .Add(new InputComponent("Description"))
        .Callback(i => project.Description = i);
prompt.Begin();

Config

public class PromptConfig
{
    public ConsoleColor QuestionColor { get; } = ConsoleColor.Gray;
    public ConsoleColor AnswerColor { get; } = ConsoleColor.Cyan;
    public ConsoleColor CursorColor { get; } = ConsoleColor.Red;
    public string Cursor { get; } = "> ";
}

Contributions

All contributions are welcome if well described.

promptcli's People

Contributors

alimozdemir avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  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.