README.md 856 Bytes
Newer Older
Alexandru Scvortov's avatar
Alexandru Scvortov committed
1
2
3
challenge-prompt
================

Alexandru Scvortov's avatar
Alexandru Scvortov committed
4
`challenge-prompt` makes the user pause before doing something.
Alexandru Scvortov's avatar
Alexandru Scvortov committed
5

Alexandru Scvortov's avatar
Alexandru Scvortov committed
6
[![Crates.io](https://img.shields.io/crates/v/challenge-prompt.svg)](https://crates.io/crates/challenge-prompt)
Alexandru Scvortov's avatar
Alexandru Scvortov committed
7

Alexandru Scvortov's avatar
Alexandru Scvortov committed
8
9
Command line tool
-----------------
Alexandru Scvortov's avatar
Alexandru Scvortov committed
10

Alexandru Scvortov's avatar
Alexandru Scvortov committed
11
Install:
Alexandru Scvortov's avatar
Alexandru Scvortov committed
12
13

    $ cargo install challenge-prompt
Alexandru Scvortov's avatar
Alexandru Scvortov committed
14
15
16
17
18
    
Run:

    $ challenge-prompt
    Solve: (5 + 15) mod 5 = ?
Alexandru Scvortov's avatar
Alexandru Scvortov committed
19

Alexandru Scvortov's avatar
Alexandru Scvortov committed
20
21
Library example
---------------
Alexandru Scvortov's avatar
Alexandru Scvortov committed
22
23
24
25

Add this to your `Cargo.toml`:

    [dependencies]
Alexandru Scvortov's avatar
Alexandru Scvortov committed
26
    challenge-prompt = "0.2"
Alexandru Scvortov's avatar
Alexandru Scvortov committed
27
28
29

and this to your crate root:

Alexandru Scvortov's avatar
Alexandru Scvortov committed
30
31
32
33
34
35
36
37
38
```rust
extern crate challenge_prompt;
```
    
Basic example:

```rust
extern crate challenge_prompt;
    
Alexandru Scvortov's avatar
Alexandru Scvortov committed
39
40
41
let mut rng = challenge_prompt::Rng::new_from_time().unwrap();
if !challenge_prompt::Challenge::Arithmetic.prompt(&mut rng) {
   panic!("user failed the challenge")
Alexandru Scvortov's avatar
Alexandru Scvortov committed
42
43
44
45
}
```

See also the full [documentation](https://docs.rs/challenge-prompt/).