Sharprompt
Interactive command line interface toolkit for .NET Core
NuGet Package
Package Name | Target Framework | NuGet |
---|---|---|
Sharprompt | .NET Standard 2.0 |
Install
Install-Package Sharprompt
dotnet add package Sharprompt
Usage
var name = Prompt.Input<string>("What's your name?");
Console.WriteLine($"Hello, {name}!");
var secret = Prompt.Password("Type new password", new[] { Validators.Required(), Validators.MinLength(8) });
Console.WriteLine("Password OK");
var answer = Prompt.Confirm("Are you ready?", defaultValue: true);
Console.WriteLine($"Your answer is {answer}");
APIs
Input
var name = Prompt.Input<string>("What's your name?");
Console.WriteLine($"Hello, {name}!");
Confirm
var answer = Prompt.Confirm("Are you ready?");
Console.WriteLine($"Your answer is {answer}");
Password
var secret = Prompt.Password("Type new password");
Console.WriteLine("Password OK");
Select
var city = Prompt.Select("Select your city", new[] { "Seattle", "London", "Tokyo" });
Console.WriteLine($"Hello, {city}!");
MultiSelect
var cities = Prompt.MultiSelect("Which cities would you like to visit?", new[] { "Seattle", "London", "Tokyo", "New York", "Singapore", "Shanghai" }, pageSize: 3);
Console.WriteLine($"You picked {string.Join(", ", options)}");
Platforms
- Windows
- Cmd / PowerShell / Windows Terminal (Preview)
- Ubuntu
- Bash
- macOS
- Bash
License
This project is licensed under the MIT License