Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alimozdemir/promptcli
Interactive command line interface library
https://github.com/alimozdemir/promptcli
cli csharp inquirer prompt
Last synced: 3 months ago
JSON representation
Interactive command line interface library
- Host: GitHub
- URL: https://github.com/alimozdemir/promptcli
- Owner: alimozdemir
- License: mit
- Created: 2020-04-05T13:35:34.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-11-28T18:47:29.000Z (about 4 years ago)
- Last Synced: 2024-11-05T18:55:40.137Z (3 months ago)
- Topics: cli, csharp, inquirer, prompt
- Language: C#
- Homepage:
- Size: 1.61 MB
- Stars: 36
- Watchers: 5
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PromptCLI
![Nuget](https://img.shields.io/nuget/v/PromptCLI) [![Azure DevOps builds](https://img.shields.io/azure-devops/build/almozdmr/PromptCLI/1)](https://dev.azure.com/almozdmr/PromptCLI/_build?definitionId=1&_a=summary) ![Coverage](https://img.shields.io/azure-devops/coverage/almozdmr/PromptCLI/1)
PromptCLI is inspired from inquirer.js and enquirer.js. It is a interactive command line interface library.
![Basics](https://github.com/lyzerk/PromptCLI/raw/master/assets/gifs/basics.gif "Basics")
# Usage
```csharp
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 Level { get; set; }[Input("Briefly explain ?")]
public string Description { get; set; }
}static void Main(string[] args)
{
var prompt = new Prompt();var obj = prompt.Run(obj);
}```
## Without POCO class (Callback Action)
You can handle a callback action after each step
```csharp
var project = new Project();var prompt = new Prompt();
prompt.Add(new InputComponent("Project Name", "Project1"))
.Callback(i => project.ProjectName = i)
.Add(new SelectComponent("License Type", new List() { "MIT", "Apache", "GNU" } ))
.Callback(i => project.License = i)
.Add(new CheckboxComponent("Features", new List() { "Linter", "Router", "Other" }))
.Callback(i => project.Features = i)
.Add(new InputComponent("Description"))
.Callback(i => project.Description = i);
prompt.Begin();
```## Config
```csharp
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; } = "> ";
}
```
# ContributionsAll contributions are welcome if well described.