challenge-prompt

Crates.iochallenge-prompt
lib.rschallenge-prompt
version0.4.0
sourcesrc
created_at2018-09-25 21:36:16.201006
updated_at2022-04-30 17:08:09.350708
descriptionchallenge-prompt makes the user pause before doing something dangerous
homepagehttps://gitlab.com/abstract-binary/challenge-prompt
repositoryhttps://gitlab.com/abstract-binary/challenge-prompt
max_upload_size
id86543
size34,282
Alexandru Scvortov (scvalex)

documentation

README

challenge-prompt

challenge-prompt makes the user pause before doing something dangerous.

Crates.io

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.

Commit count: 23

cargo fmt