Interactive command-line toolkit for .Net core with powerful controls and commands to create professional console applications.
PromptPlus was developed in c# with the netstandard2.1, .Net 6 and .Net 7 target frameworks. Visit the official page for more documentation of PromptPlus
- Features
- Migrate Version V3.3 to V4.0
- Console Engine
- Installing
- Examples
- Controls Snapshot
- Usage
- Culture
- Colors
- Hotkeys
- Keypress Extensions Emacs
- Validators
- Supported Platforms
- Inspiration Notes
- Code of Conduct
- Contributing
- License
- API Reference
- Fixed bug PromptPlus not restore terminal original setting when shutdown application
- Fixed bug Autocomplete does not change result when backspace is pressed during search
- Added Property CurrentBuffer in console drive to return Current Buffer running (Primary/Secondary)
- Added SwapBuffer command to swith Primary/Secondar buffer (Valid only When console 'ansi' suported)
- Renamed 'AlternateScreen' to 'RunOnBuffer'. Now executes a custom action on TargetBuffer and returns to CurrentBuffer
- Refactored console drivers initialization, control options initialization
- Added auto create Environment 'PromptPlusConvertCodePage' to custom automate convert codepage to unicode-codepage
- Default value is = '850;65001'
- New control to switch Alternate screen
- Fixed bug Console does not change foreground/background color correctly
- Fixed bug Control ProgressBar
- Not show gradient when setted ProgressBarType.Fill
- Improve testability of result classes/struct (Internal to public)
- New Control Pipeline
- PromptPlus.Pipeline(T startvalue)
- Changed WaitControl to take context value in tasks and return context in result
- There are small break-chages
- Add Answer key check equals "Yes"/"No" using config values
- IsYesResponseKey(this ConsoleKeyInfo keyinfo)
- IsNoResponseKey(this ConsoleKeyInfo keyinfo)
All features have IntelliSense. The PromptPlus have more 20 controls with many features like: filters, validators, history, sugestions, spinner(19 embeding type and plus custom yours!), colors and styles for control-elements :
- Banner Ascii
- Input text / Secret / AutoComplete with spinner
- MaskEdit Generic / Only Date / Only Time / DateTime / Number / Currency
- Calendar with multiple layouts
- Select and Multi-Select(with group select!)
- AddTo(Add/Remove) items for text and masked text
- Wait Keypress with animate spinner
- Slider numeric ranger with gradient colors
- Up-Down numeric ranger
- Switch (style on/off)
- Wait Process (Run background tasks Sequential/Parallel) with elapsedtime and spinner
- Wait Time with countdown and spinner
- ChartBar with enabled Interaction to switch layout, Legend and order when browse the charts / Legends.
- Progress bar with 8 types , gradient colors and spinner
- Browser File and Folder with multi-select, colors and spinner
- Treeview hierarchical structures with multi-select and colors
- Switch Alternate screen
- Execution pipeline with conditions
All controls have the same organization (see in action: Controls Snapshot):
- input/filter (except Masked input) using GNU Readline Emacs keyboard shortcuts.
- Prompt, description and data entry (ever)
- Extra actions per stage : OnStartControl/OnInputRender/OnTryAcceptInput/OnFinishControl (ever)
- Tooltips (ever and configurable)
- Filter by Contains / StartsWith (configurable) (depends on the control)
- Collection subset items and interations (depends on the control)
- Page information and page-size(depends on the control)
- Spinner animmation (depends on the control)
- Error message (depends on the control and validators)
PromptPlus driver console Supports 4/8/24-bit colors in the terminal with auto-detection of the current terminal's capabilities.
Until version 3 the console engine was based on a model from another project that has several serious problems that cause exceptions during execution in addition to increasing the complexity of the code for correct rendering... PromptPlus v4 has been completely rebuilt for a better experience, with significant improvements with new controls and more developer power. The console driver now supports better rendering, with the ability to detect terminal capabilities and allow for 24-bit color, text overflow strategies based on terminal size, and left and right margins for a nicer layout. The Controls have been revised to be more responsive, allow color styles in many of their elements, and adapt to the terminal size even with resizing.
For migrate V3.3 to V4.0 see this link.
The console driver have the ability to detect terminal capabilities and allow for 24-bit color and text overflow strategies based on terminal size, and left and right margins for a nicer layout and automatic color conversion. The new engine detects support ansi commands and adjust output for this functionality respecting OS differences , terminal mode and Windows console mode. The Colors are automatically adjusted to the capacity of the terminal. This automatic adjustment may slightly modify the final color when converting to a lower bit resolution.
Note: This layout and code was inspired by the excellent project:spectreconsole, having the same color palette
Install-Package PromptPlus [-pre]
dotnet add package PromptPlus [--prerelease]
Note: [-pre]/[--prerelease] usage for pre-release versions
The folder Samples contains more 30 samples!.
dotnet run --project [name of sample]
For each snapshot, the title is name of projet sample in folder samples
Not have snapshot
Top | InputWithSugestionSamples
Top | InputWithValidatorSamples
Other samples input
Top | InputOverwriteDefaultFromSamples
Top | MaskEditDateTimeTypeSamples
Top | MaskEditNumberTypeSamples
Top | MaskEditCurrencyTypeSamples
Other samples Select
Top | SelectUserScopeSamples , SelectUserTypeSamples
Other samples Multi-Select MultiSelectUserScopeSamples , MultiSelectUserTypeSamples
Top | SliderNumberUpDownModeSamples
Top | SliderNumberLeftRightModeSamples
Top | AddtoMaskEditListSamples
Top | BrowserMultSelectSamples
Top | TreeViewMultiSelectSamples
All controls use fluent interface; an object-oriented API whose design relies extensively on method chaining. Its goal is to increase code legibility. The term was coined in 2005 by Eric Evans and Martin Fowler.
//MaskEdit Generic
var mask = PromptPlus.MaskEdit("input", "MaskEdit Generic input")
.Mask(@"\XYZ 9{3}-L{3}-C[ABC]N{1}[XYZ]-A{3}")
.DescriptionWithInputType(FormatWeek.Short)
.Run();
if (!mask.IsAborted)
{
PromptPlus.WriteLine($"You input with mask is {mask.Value.Masked}");
PromptPlus.WriteLine($"You input without mask is {mask.Value.Input}");
}
//AnyKey
var kp1 = PromptPlus
.KeyPress()
.Run();
if (!kp1.IsAborted)
{
PromptPlus.WriteLine($"You Pressed {kp1.Value.Key}");
}
//input
var in1 = PromptPlus
.Input("Input sample1")
.Run();
if (!in1.IsAborted)
{
PromptPlus.WriteLine($"You input is {in1.Value}");
}
PromptPlus applies the language/culture only when running controls. The language/culture of the application is not affected. If language/culture is not informed, the application's language/culture will be used with fallback to en-US.
All messages are affected when changed language/culture. PromptPlus has languages embeded:
- en-US (Default)
- pt-BR
To use a non-embedded language/culture:
- Copy the PromptPlusResources.resx file in folder PromptPlus/Resources
- Translate messages with same format to your language/culture
- Convert .resx files to binary .resources files (reference link here)
- Publish the compiled file (PromptPlus.[Language].resources) in the same folder as the binaries.
PromptPlus is in accordance with informal standard NO COLOR. when there is the environment variable "no_color" the colors are disabled.
PromptPlus also has commands for coloring parts of the text using direct console, styles and Over elememnts of controls.
Promptplus uses the same default colors and engine(softly modified) as the third party project: spectreconsole. For more details visit the official page or see the samples in folder Samples
Hotkeys (global and control-specific) are configurable. Some hotkeys are internal and reserved. For more details visit the official page
PromptPlus have a lot extensions to check Key-press with GNU Readline Emacs keyboard shortcuts. For more details visit the official page
PromptPlus have a lot extensions to commons validator and validator import(No duplicate code!) For more details visit the official page or see the samples in folder Samples
private class MylCass
{
[Required(ErrorMessage = "{0} is required!")]
[MinLength(3, ErrorMessage = "Min. Length = 3.")]
[MaxLength(5, ErrorMessage = "Max. Length = 5.")]
[Display(Prompt ="My Input")]
public string MyInput { get; set; }
}
var inst = new MylCass();
PromptPlus
.Input("Input sample2", "import validator from decorate")
.Default(inst.Text)
.AddValidators(PromptValidators.ImportValidators(inst,x => x!.Text!))
.Run();
if (name.IsAborted)
{
return;
}
PromptPlus.WriteLine($"Your input: {name.Value}!");
- Windows
- Command Prompt, PowerShell, Windows Terminal
- Linux (Ubuntu, etc)
- Windows Terminal (WSL 2)
- macOS
- Terminal.app
- FIGlet was inspired by the work of FIGlet.Net.
- The colors and some of its dependencies were inspired by the work of spectreconsole.
- The API Reference was inspired by the work of xmldoc2md (Fork with improvements).
- The EastAsianWidth and base-control was inspired by the work of Sharprompt
This project has adopted the code of conduct defined by the Contributor Covenant to clarify expected behavior in our community. For more information see the Code of Conduct.
See the Contributing guide for developer documentation.
Copyright 2021 @ Fernando Cerqueira
PromptPlus project is licensed under the the MIT license. For more information see License.