4 releases (breaking)
0.4.0 | Apr 30, 2022 |
---|---|
0.3.0 | Jan 4, 2022 |
0.2.0 | Oct 27, 2018 |
0.1.0 | Sep 25, 2018 |
#2185 in Command line utilities
13KB
196 lines
challenge-prompt
challenge-prompt
makes the user pause before doing something dangerous.
Command line tool
Install:
$ cargo install challenge-prompt # with cargo
$ nix profile install 'git+https://gitlab.com/abstract-binary/challenge-prompt' # with nix
Run:
$ challenge-prompt
Solve: (5 + 15) mod 5 = ?
Usage
Usage: challenge-prompt [-a] [-p] [--phrase <phrase>] [-y] [-v] [--retries <retries>]
Make the user pause before doing something dangerous.
Options:
-a, --arithmetic prompt the user to solve a simple arithmetic problem
(default challenge)
-p, --mistake prompt the user to type in "I am probably making a mistake."
--phrase prompt the user to type in exactly the given phrase
-y, --yes prompt the user to type in 'y' or 'yes'
-v, --version print version information
--retries how many retries to allow before failing (default: 1)
--help display usage information
Notes:
Set environment variable CHALLENGE_PROMPT_SEED to an u32 to fix the RNG seed.
Error codes:
0 User passed the challenge.
1 User failed the challenge or an error was encountered.
Library example
Add this to your Cargo.toml
:
[dependencies]
challenge-prompt = "0.3"
and this to your crate root:
extern crate challenge_prompt;
Basic example:
extern crate challenge_prompt;
let mut rng = challenge_prompt::Rng::new_from_time().unwrap();
if !challenge_prompt::Challenge::Arithmetic.prompt(&mut rng) {
panic!("user failed the challenge")
}
See also the full documentation.
Dependencies
~0.4–1MB
~23K SLoC