cube_scrambler 0.3.0

Cube Scrambler is a simple yet effective random-move scramble generator API and CLI for 2x2x2, 3x3x3[default], 4x4x4, 5x5x5, 6x6x6 and 7x7x7 Rubik's Cubes, written in Rust. It ensures no two consecutive moves are the same, providing an unpredictable and challenging scramble.
Documentation
extern crate argparse;
use argparse::{ArgumentParser, StoreOption};

fn normalize_cube_type(cube_type: String) -> String {
    match cube_type.as_str() {
        "2x2" | "222" => "2x2x2".to_string(),
        "3x3" | "333" => "3x3x3".to_string(),
        "4x4" | "444" => "4x4x4".to_string(),
        "5x5" | "555" => "5x5x5".to_string(),
        "6x6" | "666" => "6x6x6".to_string(),
        "7x7" | "777" => "7x7x7".to_string(),
        other => other.to_string(),
    }
}

pub fn parse_arguments() -> (Option<u32>, Option<String>) {
    let mut n: Option<u32> = None;
    let mut cube_type: Option<String> = None;
    {
        let mut parser = ArgumentParser::new();
        parser.set_description("2x2x2, 3x3x3, 4x4x4, 5x5x5, 6x6x6 and 7x7x7 Rubik's Cubes scramble generator");
        parser.refer(&mut n)
            .add_option(&["-l", "--length"], StoreOption, "Set the number of moves of the scramble");
        parser.refer(&mut cube_type)
            .add_option(&["-t", "--type"], StoreOption, "Set the cube type (e.g., 2x2, 222, 2x2x2, ..., 7x7, 777, 7x7x7)");
        parser.parse_args_or_exit();
    }

    let normalized_cube_type = cube_type.map(normalize_cube_type);
    (n, normalized_cube_type)
}