Skip to content

Interactive command line interface library

License

Notifications You must be signed in to change notification settings

adolf94/PromptCLI

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Interactive command line interface library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%