Crates.io | question |
lib.rs | question |
version | 0.2.2 |
source | src |
created_at | 2017-11-02 14:23:05.9397 |
updated_at | 2018-05-08 19:58:25.783126 |
description | Ask a question, what more could you want? |
homepage | https://gitlab.com/starshell/question |
repository | https://gitlab.com/starshell/question |
max_upload_size | |
id | 37794 |
size | 37,757 |
A Command Line Question Asker for Rust.
Ask a question, what more could you want?
Easy to use library for asking users questions when writing console/terminal applications.
Add question
as a dependency in your Cargo.toml
to use from crates.io:
[dependencies]
question = "0.2.2"
Then add extern crate question;
to your crate root and run cargo build
or cargo update && cargo build
for your project. Detailed documentation for releases can be found on docs.rs and the bleeding edge docs for the latest GitLab repository version can be found on GitLab pages.
extern crate question;
use question::{Answer, Question};
fn main() {
let answer = Question::new("Continue?")
.default(Answer::YES)
.show_defaults()
.confirm();
if answer == Answer::YES {
println!("Onward then!");
} else {
println!("Aborting...");
}
}
Examples can also be ran directly:
$ cargo run --example yes_no_with_defaults
Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs
Running `target/debug/examples/yes_no_with_defaults`
Continue? (Y/n) why
Continue? (Y/n) y
Onward then!
See examples for more.
The project is mirrored to GitHub, but all development is done on GitLab. Please use the GitLab issue tracker. Don't have a GitLab account? Just email incoming+starshell/question@gitlab.com
and those emails automatically become issues (with the comments becoming the email conversation).
To contribute to Question, please see CONTRIBUTING.
Question is distributed under the terms of both the MIT license. If this does not suit your needs for some reason please feel free to contact me, or open an issue.
See LICENSE.