{"id":13590729,"url":"https://github.com/shibayan/Sharprompt","last_synced_at":"2025-04-08T14:31:35.059Z","repository":{"id":37768270,"uuid":"199499570","full_name":"shibayan/Sharprompt","owner":"shibayan","description":"Interactive command-line based application framework for C#","archived":false,"fork":false,"pushed_at":"2024-04-29T02:13:07.000Z","size":340,"stargazers_count":711,"open_issues_count":15,"forks_count":46,"subscribers_count":15,"default_branch":"master","last_synced_at":"2024-05-02T05:07:44.166Z","etag":null,"topics":["cli","command-line","csharp","dotnet","interactive","prompt","terminal"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shibayan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"shibayan","custom":"paypal.me/shibayan"}},"created_at":"2019-07-29T17:38:55.000Z","updated_at":"2024-06-03T05:33:49.368Z","dependencies_parsed_at":"2023-12-18T03:22:41.481Z","dependency_job_id":"982d633c-2f02-4b9c-81d6-914f8cdcd96e","html_url":"https://github.com/shibayan/Sharprompt","commit_stats":null,"previous_names":[],"tags_count":49,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shibayan%2FSharprompt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shibayan%2FSharprompt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shibayan%2FSharprompt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shibayan%2FSharprompt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shibayan","download_url":"https://codeload.github.com/shibayan/Sharprompt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247860662,"owners_count":21008329,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","command-line","csharp","dotnet","interactive","prompt","terminal"],"created_at":"2024-08-01T16:00:49.918Z","updated_at":"2025-04-08T14:31:34.683Z","avatar_url":"https://github.com/shibayan.png","language":"C#","readme":"# Sharprompt\n\n[![Build](https://github.com/shibayan/Sharprompt/workflows/Build/badge.svg)](https://github.com/shibayan/Sharprompt/actions/workflows/build.yml)\n[![Downloads](https://badgen.net/nuget/dt/Sharprompt)](https://www.nuget.org/packages/Sharprompt/)\n[![NuGet](https://badgen.net/nuget/v/Sharprompt)](https://www.nuget.org/packages/Sharprompt/)\n[![License](https://badgen.net/github/license/shibayan/Sharprompt)](https://github.com/shibayan/Sharprompt/blob/master/LICENSE)\n\nInteractive command-line based application framework for C#\n\n![sharprompt](https://user-images.githubusercontent.com/1356444/62227794-87506e00-b3f7-11e9-84ae-06c9a900448b.gif)\n\n## Features\n\n- Multi-platform support\n- Supports the popular prompts (`Input` / `Password` / `Select` / etc)\n- Supports model-based prompts\n- Validation of input value\n- Automatic generation of data source using Enum type\n- Customizable symbols and color schema\n- Unicode support (Multi-byte characters and Emoji😀🎉)\n\n## Installation\n\n```\nInstall-Package Sharprompt\n```\n\n```\ndotnet add package Sharprompt\n```\n\n```csharp\n// Simple input\nvar name = Prompt.Input\u003cstring\u003e(\"What's your name?\");\nConsole.WriteLine($\"Hello, {name}!\");\n\n// Password input\nvar secret = Prompt.Password(\"Type new password\", validators: new[] { Validators.Required(), Validators.MinLength(8) });\nConsole.WriteLine(\"Password OK\");\n\n// Confirmation\nvar answer = Prompt.Confirm(\"Are you ready?\", defaultValue: true);\nConsole.WriteLine($\"Your answer is {answer}\");\n```\n\n## Examples\n\nThe project in the folder `Sharprompt.Example` contains all the samples. Please check it.\n\n```\ndotnet run --project Sharprompt.Example\n```\n\n## Prompt types\n\n### Input\n\nTakes a generic type parameter and performs type conversion as appropriate.\n\n```csharp\nvar name = Prompt.Input\u003cstring\u003e(\"What's your name?\");\nConsole.WriteLine($\"Hello, {name}!\");\n\nvar number = Prompt.Input\u003cint\u003e(\"Enter any number\");\nConsole.WriteLine($\"Input = {number}\");\n```\n\n![input](https://user-images.githubusercontent.com/1356444/62228275-50c72300-b3f8-11e9-8d51-63892e8eeaaa.gif)\n\n### Confirm\n\n```csharp\nvar answer = Prompt.Confirm(\"Are you ready?\");\nConsole.WriteLine($\"Your answer is {answer}\");\n```\n\n![confirm](https://user-images.githubusercontent.com/1356444/62229064-e0210600-b3f9-11e9-8c52-b9c9257811c0.gif)\n\n### Password\n\n```csharp\nvar secret = Prompt.Password(\"Type new password\");\nConsole.WriteLine(\"Password OK\");\n```\n\n![password](https://user-images.githubusercontent.com/1356444/62228952-9fc18800-b3f9-11e9-98ea-3aa52ee84e93.gif)\n\n### Select\n\n```csharp\nvar city = Prompt.Select(\"Select your city\", new[] { \"Seattle\", \"London\", \"Tokyo\" });\nConsole.WriteLine($\"Hello, {city}!\");\n```\n\n![select](https://user-images.githubusercontent.com/1356444/62228719-2de93e80-b3f9-11e9-8be5-f19e6ef58aeb.gif)\n\n### MultiSelect (Checkbox)\n\n```csharp\nvar cities = Prompt.MultiSelect(\"Which cities would you like to visit?\", new[] { \"Seattle\", \"London\", \"Tokyo\", \"New York\", \"Singapore\", \"Shanghai\" }, pageSize: 3);\nConsole.WriteLine($\"You picked {string.Join(\", \", cities)}\");\n```\n\n![multiselect](https://user-images.githubusercontent.com/1356444/127033929-3278e39c-e260-4aed-9c3c-3cfd7d3f3549.gif)\n\n### List\n\n```csharp\nvar value = Prompt.List\u003cstring\u003e(\"Please add item(s)\");\nConsole.WriteLine($\"You picked {string.Join(\", \", value)}\");\n```\n\n![list](https://user-images.githubusercontent.com/1356444/127033968-cf70bd1b-bcd1-4c4f-bdbe-74aae52cdb86.gif)\n\n### Bind (Model-based prompts)\n\n```csharp\n// Input model definition\npublic class MyFormModel\n{\n    [Display(Name = \"What's your name?\")]\n    [Required]\n    public string Name { get; set; }\n\n    [Display(Name = \"Type new password\")]\n    [DataType(DataType.Password)]\n    [Required]\n    [MinLength(8)]\n    public string Password { get; set; }\n\n    [Display(Name = \"Select your city\")]\n    [Required]\n    [InlineItems(\"Seattle\", \"London\", \"Tokyo\")]\n    public string City { get; set; }\n\n    [Display(Name = \"Are you ready?\")]\n    public bool? Ready { get; set; }\n}\n\nvar result = Prompt.Bind\u003cMyFormModel\u003e();\n```\n\n## Configuration\n\n### Symbols\n\n```csharp\nPrompt.Symbols.Prompt = new Symbol(\"🤔\", \"?\");\nPrompt.Symbols.Done = new Symbol(\"😎\", \"V\");\nPrompt.Symbols.Error = new Symbol(\"😱\", \"\u003e\u003e\");\n\nvar name = Prompt.Input\u003cstring\u003e(\"What's your name?\");\nConsole.WriteLine($\"Hello, {name}!\");\n```\n\n### Color schema\n\n```csharp\nPrompt.ColorSchema.Answer = ConsoleColor.DarkRed;\nPrompt.ColorSchema.Select = ConsoleColor.DarkCyan;\n\nvar name = Prompt.Input\u003cstring\u003e(\"What's your name?\");\nConsole.WriteLine($\"Hello, {name}!\");\n```\n\n### Cancellation support\n\n```csharp\n// Throw an exception when canceling with Ctrl-C\nPrompt.ThrowExceptionOnCancel = true;\n\ntry\n{\n    var name = Prompt.Input\u003cstring\u003e(\"What's your name?\");\n    Console.WriteLine($\"Hello, {name}!\");\n}\ncatch (PromptCanceledException ex)\n{\n    Console.WriteLine(\"Prompt canceled\");\n}\n```\n\n## Features\n\n### Enum type support\n\n```csharp\npublic enum MyEnum\n{\n    [Display(Name = \"First value\")]\n    First,\n    [Display(Name = \"Second value\")]\n    Second,\n    [Display(Name = \"Third value\")]\n    Third\n}\n\nvar value = Prompt.Select\u003cMyEnum\u003e(\"Select enum value\");\nConsole.WriteLine($\"You selected {value}\");\n```\n\n### Unicode support\n\n```csharp\n// Prefer UTF-8 as the output encoding\nConsole.OutputEncoding = Encoding.UTF8;\n\nvar name = Prompt.Input\u003cstring\u003e(\"What's your name?\");\nConsole.WriteLine($\"Hello, {name}!\");\n```\n\n![unicode support](https://user-images.githubusercontent.com/1356444/89803983-86a3f900-db6e-11ea-8fc8-5b6f9ef5644f.gif)\n\n### Fluent interface support\n\n```csharp\nusing Sharprompt.Fluent;\n\n// Use fluent interface\nvar city = Prompt.Select\u003cstring\u003e(o =\u003e o.WithMessage(\"Select your city\")\n                                       .WithItems(new[] { \"Seattle\", \"London\", \"Tokyo\" })\n                                       .WithDefaultValue(\"Seattle\"));\n```\n\n## Supported platforms\n\n- Windows\n  - Command Prompt\n  - PowerShell\n  - Windows Terminal\n- Linux (Ubuntu, etc)\n  - Windows Terminal (WSL 2)\n- macOS\n  - Terminal.app\n\n## License\n\nThis project is licensed under the [MIT License](https://github.com/shibayan/Sharprompt/blob/master/LICENSE)\n","funding_links":["https://github.com/sponsors/shibayan","paypal.me/shibayan"],"categories":["C# #","C\\#","Console UI","C#"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshibayan%2FSharprompt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshibayan%2FSharprompt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshibayan%2FSharprompt/lists"}