askit
askit is a simple and semantic Rust library to handle interactive CLI
prompts, inspired by Python's input.
It provides an ergonomic and type-safe way to ask users for values,
validate them, and display custom messages.
Features
ask!macro: The simplest way to get input, panics on error. Perfect for quick scripts and demos.\input!macro: Safe version, returnsResult<T, Error>so you can handle errors gracefully.\.force()helper: Lets you call.force()on aninput!result to panic on error.\- Typed input: Directly parse inputs into Rust types like
i32,f64,bool,String, and more.\ - Validation: Attach custom validation logic.\
- Messages: Attach messages or hints to guide the user.\
- Defaults: Provide default values if the user presses Enter.
Installation
Add the following to your Cargo.toml:
[]
= "0.1.0"
Quickstart with ask! (recommended)
use ask;
Usage Variations
1. ask! macro (recommended, panics on error)
use ask;
2. input! macro (safe, returns Result)
use input;
3. .force() helper on input! (shortcut)
use ;
Advanced Usage with prompt() Builder
use prompt;
Running Examples
Testing
License
MIT License.