Fluent Input 🦀
Simple, fluent input for Rust CLI apps — easier to use than the standard std::io.
Install
Add to your project's Cargo.toml (example):
[]
= { = "https://github.com/lilcloudcoder/RustInput" }
Note: inside this repository the crate name is RustInput (PascalCase). In external projects, Cargo will expose it as rustinput (snake_case).
Quick start
// In external projects
use input; // or: use rustinput::Input;
Inside this repo's examples/binary use:
use input;
Features
- Ergonomic prompts:
input("Your age: ").int::<i32>() - All integer and float types supported via
FromStr - Strings and booleans with common aliases (
y/yes/true/1,n/no/false/0) - New helpers:
char()— read a single characteroptional::<T>() -> Option<T>— Enter to skipdefault::<T>(value) -> T— Enter to accept defaultchoices(&["light", "dark"]) -> String— restrict to allowed values (case-insensitive)
API cheatsheet
use input;
let i: i64 = input.int;
let u: usize = input.int;
let f: f32 = input.float;
let s: String = input.string;
let b: bool = input.bool;
let c: char = input.char;
let maybe_n: = input.optional;
let tries: u32 = input.default;
let theme: String = input.choices;
Types supported
- Integers: all signed/unsigned (
i8..i128,u8..u128,isize,usize) - Floats:
f32,f64 - Bool, String, Char