VOOZH about

URL: https://www.nuget.org/packages/Sharprompt/

โ‡ฑ NuGet Gallery | Sharprompt 3.1.1


๏ปฟ

๐Ÿ‘ Image
Sharprompt 3.1.1

dotnet add package Sharprompt --version 3.1.1
 
 
NuGet\Install-Package Sharprompt -Version 3.1.1
 
 
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Sharprompt" Version="3.1.1" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Sharprompt" Version="3.1.1" />
 
Directory.Packages.props
<PackageReference Include="Sharprompt" />
 
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Sharprompt --version 3.1.1
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Sharprompt, 3.1.1"
 
 
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Sharprompt@3.1.1
 
 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Sharprompt&version=3.1.1
 
Install as a Cake Addin
#tool nuget:?package=Sharprompt&version=3.1.1
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Sharprompt

๐Ÿ‘ Build
๐Ÿ‘ Downloads
๐Ÿ‘ NuGet
๐Ÿ‘ License

Interactive command-line based application framework for C#

๐Ÿ‘ sharprompt

Features

  • Multi-platform support
  • Supports the popular prompts (Input / Password / Select / etc)
  • Supports model-based prompts
  • Validation of input value
  • Automatic generation of data source using Enum type
  • Customizable symbols and color schema
  • Unicode support (Multi-byte characters and Emoji๐Ÿ˜€๐ŸŽ‰)

Installation

Install-Package Sharprompt
dotnet add package Sharprompt

Quick start

// Simple input
var name = Prompt.Input<string>("What's your name?");
Console.WriteLine($"Hello, {name}!");

// Password input
var secret = Prompt.Password("Type new password", validators: new[] { Validators.Required(), Validators.MinLength(8) });
Console.WriteLine("Password OK");

// Confirmation
var answer = Prompt.Confirm("Are you ready?", defaultValue: true);
Console.WriteLine($"Your answer is {answer}");

Examples

The project in the folder samples/Sharprompt.Example contains all the samples. Please check it.

dotnet run --project samples/Sharprompt.Example

Prompt types

Input

Takes a generic type parameter and performs type conversion as appropriate.

var name = Prompt.Input<string>("What's your name?");
Console.WriteLine($"Hello, {name}!");

var number = Prompt.Input<int>("Enter any number");
Console.WriteLine($"Input = {number}");

๐Ÿ‘ input

Confirm

var answer = Prompt.Confirm("Are you ready?");
Console.WriteLine($"Your answer is {answer}");

๐Ÿ‘ confirm

Password

var secret = Prompt.Password("Type new password");
Console.WriteLine("Password OK");

๐Ÿ‘ password

Select

var city = Prompt.Select("Select your city", new[] { "Seattle", "London", "Tokyo" });
Console.WriteLine($"Hello, {city}!");

๐Ÿ‘ select

MultiSelect (Checkbox)

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(", ", cities)}");

๐Ÿ‘ multiselect

List

var value = Prompt.List<string>("Please add item(s)");
Console.WriteLine($"You picked {string.Join(", ", value)}");

๐Ÿ‘ list

Bind (Model-based prompts)

// Input model definition
public class MyFormModel
{
 [Display(Name = "What's your name?")]
 [Required]
 public string Name { get; set; }

 [Display(Name = "Type new password")]
 [DataType(DataType.Password)]
 [Required]
 [MinLength(8)]
 public string Password { get; set; }

 [Display(Name = "Select your city")]
 [Required]
 [InlineItems("Seattle", "London", "Tokyo")]
 public string City { get; set; }

 [Display(Name = "Are you ready?")]
 public bool? Ready { get; set; }
}

var result = Prompt.Bind<MyFormModel>();

Configuration

Symbols

Prompt.Symbols.Prompt = new Symbol("๐Ÿค”", "?");
Prompt.Symbols.Done = new Symbol("๐Ÿ˜Ž", "V");
Prompt.Symbols.Error = new Symbol("๐Ÿ˜ฑ", ">>");

var name = Prompt.Input<string>("What's your name?");
Console.WriteLine($"Hello, {name}!");

Color schema

Prompt.ColorSchema.Answer = ConsoleColor.DarkRed;
Prompt.ColorSchema.Select = ConsoleColor.DarkCyan;

var name = Prompt.Input<string>("What's your name?");
Console.WriteLine($"Hello, {name}!");

Cancellation support

// Throw an exception when canceling with Ctrl-C
Prompt.ThrowExceptionOnCancel = true;

try
{
 var name = Prompt.Input<string>("What's your name?");
 Console.WriteLine($"Hello, {name}!");
}
catch (PromptCanceledException ex)
{
 Console.WriteLine("Prompt canceled");
}

Validators

Sharprompt provides built-in validators that can be used with the validators parameter.

var secret = Prompt.Password("Type new password", validators: new[] { Validators.Required(), Validators.MinLength(8) });
Validator Description
Validators.Required() Ensures the input is not empty
Validators.MinLength(length) Ensures the input has at least the specified number of characters
Validators.MaxLength(length) Ensures the input does not exceed the specified number of characters
Validators.RegularExpression(pattern) Ensures the input matches the specified regular expression

Additional features

Enum type support

public enum MyEnum
{
 [Display(Name = "First value")]
 First,
 [Display(Name = "Second value")]
 Second,
 [Display(Name = "Third value")]
 Third
}

var value = Prompt.Select<MyEnum>("Select enum value");
Console.WriteLine($"You selected {value}");

Unicode support

// Prefer UTF-8 as the output encoding
Console.OutputEncoding = Encoding.UTF8;

var name = Prompt.Input<string>("What's your name?");
Console.WriteLine($"Hello, {name}!");

๐Ÿ‘ unicode support

Fluent interface support

using Sharprompt.Fluent;

// Use fluent interface
var city = Prompt.Select<string>(o => o.WithMessage("Select your city")
 .WithItems(new[] { "Seattle", "London", "Tokyo" })
 .WithDefaultValue("Seattle"));

Supported platforms

  • Windows
    • Command Prompt
    • PowerShell
    • Windows Terminal
  • Linux (Ubuntu, etc)
    • Windows Terminal (WSL 2)
  • macOS
    • Terminal.app

Contributing

Please see for local setup, validation commands, and pull request expectations.

Security

Please see for how to report vulnerabilities privately.

License

This project is licensed under the MIT License

Product Versions Compatible and additional computed target framework versions.
.NET net8.0 net8.0 is compatible.  net8.0-android net8.0-android was computed.  net8.0-browser net8.0-browser was computed.  net8.0-ios net8.0-ios was computed.  net8.0-maccatalyst net8.0-maccatalyst was computed.  net8.0-macos net8.0-macos was computed.  net8.0-tvos net8.0-tvos was computed.  net8.0-windows net8.0-windows was computed.  net9.0 net9.0 was computed.  net9.0-android net9.0-android was computed.  net9.0-browser net9.0-browser was computed.  net9.0-ios net9.0-ios was computed.  net9.0-maccatalyst net9.0-maccatalyst was computed.  net9.0-macos net9.0-macos was computed.  net9.0-tvos net9.0-tvos was computed.  net9.0-windows net9.0-windows was computed.  net10.0 net10.0 was computed.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages (7)

Showing the top 5 NuGet packages that depend on Sharprompt:

Package Downloads
NukeBuildHelpers

NukeBuildHelpers for Nuke build.

Dabit.Utils.YamlConfigManager

Package Description

NiuX

NiuX ๅŸบ็ก€่ฎพๆ–ฝ

Filepicker

Simple CLI UI filepicker with directory navigation

42.CLI.Toolkit

Handy toolkit for a fancy CLI application.

GitHub repositories (12)

Showing the top 12 popular GitHub repositories that depend on Sharprompt:

Repository Stars
AutoDarkMode/Windows-Auto-Night-Mode
Automatically switches between the dark and light theme of Windows 10 and Windows 11
github/gh-actions-importer
GitHub Actions Importer helps you plan and automate the migration of Azure DevOps, Bamboo, Bitbucket, CircleCI, GitLab, Jenkins, and Travis CI pipelines to GitHub Actions.
microsoft/winget-create
The Windows Package Manager Manifest Creator command-line tool (aka wingetcreate)
github/gh-valet
Valet helps facilitate the migration of Azure DevOps, CircleCI, GitLab CI, Jenkins, and Travis CI pipelines to GitHub Actions.
void-stack/VMUnprotect.Dumper
VMUnprotect.Dumper can dynamically untamper VMProtected Assembly.
Maoni0/realmon
A monitoring tool that tells you when GCs happen in a process and some characteristics about these GCs
mayuki/Chell
Write scripts with the power of C# and .NET
OpenTouryoProject/OpenTouryo
โ€OpenๆฃŸๆขโ€ใฏใ€้•ทๅนดใฎ.NETใ‚ขใƒ—ใƒชใ‚ฑใƒผใ‚ทใƒงใƒณ้–‹็™บๅฎŸ็ธพใซใฆ่“„็ฉใ—ใŸใƒŽใ‚ฆใƒใ‚ฆใซๅŸบใฅใ้–‹็™บใ—ใŸ.NET็”จใ‚ขใƒ—ใƒชใ‚ฑใƒผใ‚ทใƒงใƒณ ใƒ•ใƒฌใƒผใƒ ใƒฏใƒผใ‚ฏใงใ™ใ€‚ (โ€OpenTouryoโ€ , is an application framework for .NET which was developed using the accumulated know-how with a long track record in .NET application development.)
void-stack/VMAttack
Research on code virtualization in .NET [WIP]
Serg-Norseman/GEDKeeper
GEDKeeper - program for work with personal genealogical database
ingen084/KyoshinEewViewerIngen
Custom client for Kyoshin Monitor
FrostyToolsuite/FrostyToolsuite
The most advanced modding platform for games running on DICE's Frostbite game engine.
Version Downloads Last Updated
3.1.1 53,426 4/14/2026
3.1.0 582 4/9/2026
3.1.0-preview2 114 3/31/2026
3.1.0-preview1 128 3/5/2026
3.0.1 128,801 9/22/2025
3.0.0 99,392 1/8/2025
3.0.0-preview5 747 11/16/2024
3.0.0-preview4 8,287 9/4/2023
3.0.0-preview3 802 8/12/2023
3.0.0-preview2 15,627 11/29/2022
3.0.0-preview1 834 11/13/2022
2.4.5 721,915 9/27/2022
2.4.4 11,364 8/26/2022
2.4.3 17,393 7/13/2022
2.4.2 4,096 7/6/2022
2.4.1 40,971 4/4/2022
2.4.0 19,422 12/31/2021
2.4.0-preview3 957 12/13/2021
2.4.0-preview2 856 12/10/2021
2.4.0-preview1 984 11/14/2021
Loading failed