question 0.2.0

Ask a question, what more could you want?
Documentation

Question

Crates.io Crates.io license Coverage Status

Linux: Build status Windows: Build status

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.


Warning: This is my first released rust project, still very new, and not yet completely tested. That said it is very small and focused so it should come together quickly, and will likely continue to be maintained/extended since I write lots of CLI applications.

Also, as indicated by the version none of the public API is yet stable. Suggestions are welcome.

Usage

Add question as a dependency in your Cargo.toml to use from crates.io:

[dependencies]
question = "0.2.0"

Then add extern crate question; to your crate root and run cargo build or cargo update && cargo build for your project.

Example

See examples for more.

extern crate question;
use question::{Question, Answer};

fn main() {
    let question = "What is the answer to the Ultimate Question of Life, the Universe, and Everything?";
    let answer = Question::new(question).ask().unwrap();
    let correct = Answer::RESPONSE(String::from("42"));
    assert_eq!(answer, correct);
}

Examples can also be ran directly:

$ cargo run --example yes_no_with_defaults
   Compiling question v0.2.0 (file:///home/datenstrom/workspace/starshell/question)
    Finished dev [unoptimized + debuginfo] target(s) in 8.75 secs
     Running `target/debug/examples/yes_no_with_defaults`
Continue? (Y/n) why
Continue? (Y/n) yes

Contributing

The project is mirrored to GitHub, but all development is done on GitLab. Please use the GitLab issue tracker.

To contribute to Question, please see CONTRIBUTING.

License

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.