https://github.com/jooapa/jread
The ultimate cross-platform C# console input library.
https://github.com/jooapa/jread
cli console cross-platform csharp dotnet input input-output library output
Last synced: about 2 months ago
JSON representation
The ultimate cross-platform C# console input library.
- Host: GitHub
- URL: https://github.com/jooapa/jread
- Owner: jooapa
- License: zlib
- Created: 2025-08-23T17:15:15.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-11-06T00:37:23.000Z (8 months ago)
- Last Synced: 2025-11-06T02:33:27.735Z (8 months ago)
- Topics: cli, console, cross-platform, csharp, dotnet, input, input-output, library, output
- Language: C#
- Homepage:
- Size: 118 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# JRead
**JRead** is the ultimate cross-platform C# console input library for .NET 8+
---
### Simple Example
```csharp
using JRead;
// Basic input
string name = JRead.Read("Enter your name: ");
Console.WriteLine($"Hello, {name}!");
// Input with prefilled text
string edited = JRead.Read("Edit this: ", "DefaultValue");
Console.WriteLine($"Final value: {edited}");
```
### Advanced Example
```csharp
using JRead;
var options = new JReadOptions
{
EnableMaskedInput = true, // Hide password input
MaskedInputChar = '*', // Use * for masking
EnableAutoComplete = true, // Enable tab completion
AutoCompleteItems = new List { "admin", "user", "guest" },
AutoCompleteMinLength = 2, // Show suggestions after 2 chars
AddReturnedValueToHistory = false, // Don't save passwords to history
EscapingReturnsTheOriginalInput = false // ESC returns null
};
string? password = JRead.ReadNull("Password: ", options: options);
if (password == null)
{
Console.WriteLine("Login cancelled!");
return;
}
```
## JReadOptions Reference
**`CustomHistory`** (`JReadHistory?`, default: `null`)
Custom history instance instead of global history
**`EnableDebug`** (`bool`, default: `false`)
Print debug information for key presses
**`AddReturnedValueToHistory`** (`bool`, default: `true`)
Add the returned value to command history
**`EscapingReturnsTheOriginalInput`** (`bool`, default: `true`)
If true, ESC returns original input; if false, returns null
**`AutoCompleteItems`** (`List`, default: `[]`)
List of autocomplete suggestions
**`EnableAutoComplete`** (`bool`, default: `true`)
Enable tab-completion functionality
**`AutoCompleteMinLength`** (`int`, default: `1`)
Minimum characters before showing suggestions
**`AutoCompleteCaseSensitive`** (`bool`, default: `false`)
Case-sensitive autocomplete matching
**`EnableMaskedInput`** (`bool`, default: `false`)
Mask input characters (for passwords)
**`MaskedInputChar`** (`char`, default: `'*'`)
Character used for masking input
**`NewLineOnExit`** (`bool`, default: `true`)
Add newline when input completes
**`MaxDisplayLength`** (`int?`, default: `null`)
Maximum characters to display (windowed view)
**`SubtractFromAvailableSpace`** (`bool`, default: `false`)
Subtract MaxDisplayLength from console width
## Technical Definitions
```csharp
string Read(string startText = "", string? preText = null, JReadOptions? options = null);
string? ReadNull(string startText = "", string? preText = null, JReadOptions? options = null);
string Read(string? startText = null, JReadOptions? options = null);
string? ReadNull(string? startText = null, JReadOptions? options = null);
string Read(string? startText = null);
string? ReadNull(string? startText = null);
```
## Keyboard Shortcuts
| Shortcut | Action |
|----------|--------|
| `Arrow Keys` | Move cursor left/right |
| `Ctrl + Left/Right` | Move by word |
| `Home/End` | Move to start/end of line |
| `Backspace/Delete` | Delete characters |
| `Ctrl + W` | Delete word to the left |
| `Ctrl + U/Z` | Undo last action |
| `Ctrl + Y` | Redo last undone action |
| `Up/Down Arrows` | Navigate command history |
| `Tab` | Autocomplete (if enabled) |
| `Enter` | Submit input |
| `Escape` | Cancel or return original (based on options) |