Crates.io | proceed |
lib.rs | proceed |
version | 0.1.0 |
source | src |
created_at | 2018-07-30 14:55:01.51313 |
updated_at | 2020-09-11 03:40:14.00289 |
description | A simple rust cli abstraction for accepting user-input. |
homepage | |
repository | https://git.sr.ht/~dstar4138/proceed |
max_upload_size | |
id | 76652 |
size | 17,118 |
Current Release: v0.1.0
A simple set of common utility functions for checking with the user of your command line application.
proceed(bool)
- Y/N with default.any_or_quit_with(char)
- Any key unless char for quit.These are wrappers around a flexible user-input checker, so you can customize as needed.
no_std
- We need std I/O.Just check yes or no, with a default of either YES
or NO
.
use proceed::{proceed, NO};
fn main() {
print!("Are you sure? [y/N]");
if !proceed(NO) {
return;
}
// Do things now that we got confirmation.
}
Continue on any user input (but 'q' for quit).
Needs term
feature enabled, otherwise user will need to press "Enter" afterwards.
use proceed::any_or_quit;
fn main() {
println!("We are about to do something expensive.");
print!("Press any key to continue, or 'q' to quit.");
if !any_or_quit_with('q') {
println!("Quitting.");
return;
}
// Do expensive operation.
}