movey_core/
commands.rs

1use super::hazard;
2use super::error;
3
4use utils::app_config::AppConfig;
5use utils::error::Result;
6
7/// Show the configuration file
8pub fn hazard() -> Result<()> {
9    // Generate, randomly, True or False
10    let random_hazard: bool = hazard::generate_hazard()?;
11
12    if random_hazard {
13        println!("You got it right!");
14    } else {
15        println!("You got it wrong!");
16    }
17
18    Ok(())
19}
20
21/// Show the configuration file
22pub fn config() -> Result<()> {
23    let config = AppConfig::fetch()?;
24    println!("{:#?}", config);
25
26    Ok(())
27}
28
29/// Simulate an error
30pub fn simulate_error() -> Result<()> {
31
32    // Log this Error simulation
33    log::info!("We are simulating an error");
34
35    // Simulate an error
36    error::simulate_error()?;
37
38    // We should never get here...
39    Ok(())
40}