4 releases

Uses old Rust 2015

0.2.2 May 8, 2018
0.2.1 Nov 9, 2017
0.2.0 Nov 5, 2017
0.1.0 Nov 2, 2017

#719 in Command-line interface

Download history 1311/week @ 2024-07-22 1195/week @ 2024-07-29 1411/week @ 2024-08-05 1508/week @ 2024-08-12 1334/week @ 2024-08-19 1500/week @ 2024-08-26 1188/week @ 2024-09-02 1036/week @ 2024-09-09 1221/week @ 2024-09-16 953/week @ 2024-09-23 1230/week @ 2024-09-30 1332/week @ 2024-10-07 1370/week @ 2024-10-14 1320/week @ 2024-10-21 1126/week @ 2024-10-28 1522/week @ 2024-11-04

5,393 downloads per month
Used in fewer than 24 crates

MIT license

30KB
495 lines

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.

Usage

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.

Example

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.

Contributing

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.

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.

Dependencies

~0–1.3MB
~31K SLoC