Crates.io | challenge-prompt |
lib.rs | challenge-prompt |
version | 0.4.0 |
source | src |
created_at | 2018-09-25 21:36:16.201006 |
updated_at | 2022-04-30 17:08:09.350708 |
description | challenge-prompt makes the user pause before doing something dangerous |
homepage | https://gitlab.com/abstract-binary/challenge-prompt |
repository | https://gitlab.com/abstract-binary/challenge-prompt |
max_upload_size | |
id | 86543 |
size | 34,282 |
challenge-prompt
makes the user pause before doing something dangerous.
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: 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.
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.