diff --git a/Cargo.lock b/Cargo.lock index 775f4c6..f8ee1c3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,23 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi", + "libc", + "winapi", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + [[package]] name = "bitflags" version = "1.3.2" @@ -14,6 +31,45 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "clap" +version = "3.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2dbdf4bdacb33466e854ce889eee8dfd5729abf7ccd7664d0a2d60cd384440b" +dependencies = [ + "atty", + "bitflags", + "clap_derive", + "clap_lex", + "indexmap", + "lazy_static", + "strsim", + "termcolor", + "textwrap", +] + +[[package]] +name = "clap_derive" +version = "3.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25320346e922cffe59c0bbc5410c8d8784509efb321488971081313cb1e1a33c" +dependencies = [ + "heck", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a37c35f1112dad5e6e0b1adaff798507497a18fceeb30cceb3bae7d1427b9213" +dependencies = [ + "os_str_bytes", +] + [[package]] name = "getrandom" version = "0.2.6" @@ -25,6 +81,37 @@ dependencies = [ "wasi", ] +[[package]] +name = "hashbrown" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" + +[[package]] +name = "heck" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" + +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + +[[package]] +name = "indexmap" +version = "1.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6012d540c5baa3589337a98ce73408de9b5a25ec9fc2c6fd6be8f0d39e0ca5a" +dependencies = [ + "autocfg", + "hashbrown", +] + [[package]] name = "labirust" version = "0.2.1" @@ -33,6 +120,20 @@ dependencies = [ "termion", ] +[[package]] +name = "labirust-cli" +version = "0.1.0" +dependencies = [ + "clap", + "labirust", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + [[package]] name = "libc" version = "0.2.126" @@ -45,12 +146,60 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef" +[[package]] +name = "os_str_bytes" +version = "6.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21326818e99cfe6ce1e524c2a805c189a99b5ae555a35d19f9a284b427d86afa" + [[package]] name = "ppv-lite86" version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + +[[package]] +name = "proc-macro2" +version = "1.0.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c54b25569025b7fc9651de43004ae593a75ad88543b17178aa5e1b9c4f15f56f" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1" +dependencies = [ + "proc-macro2", +] + [[package]] name = "rand" version = "0.8.5" @@ -99,6 +248,32 @@ dependencies = [ "redox_syscall", ] +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + +[[package]] +name = "syn" +version = "1.0.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbaf6116ab8924f39d52792136fb74fd60a80194cf1b1c6ffa6453eef1c3f942" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "termcolor" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" +dependencies = [ + "winapi-util", +] + [[package]] name = "termion" version = "1.5.6" @@ -111,8 +286,57 @@ dependencies = [ "redox_termios", ] +[[package]] +name = "textwrap" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb" + +[[package]] +name = "unicode-ident" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d22af068fba1eb5edcb4aea19d382b2a3deb4c8f9d475c589b6ada9e0fd493ee" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + [[package]] name = "wasi" version = "0.10.2+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/Cargo.toml b/Cargo.toml index ab69e17..509c747 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,12 +1,2 @@ -[package] -name = "labirust" -version = "0.2.1" -edition = "2021" -license = "MIT" -authors = ["JOLIMAITRE Matthieu "] -description = "Naive rust crate for implementing and testing maze solving Algorithms." -repository = "https://github.com/MajorBarnulf/labirust/" - -[dependencies] -rand = "0.8" -termion = "1.5" +[workspace] +members = ["labirust", "labirust-cli"] diff --git a/labirust-cli/Cargo.toml b/labirust-cli/Cargo.toml new file mode 100644 index 0000000..e5830d1 --- /dev/null +++ b/labirust-cli/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "labirust-cli" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +labirust = { path = "../labirust" } +clap = { version = "3.1.18", features = ["derive"] } diff --git a/labirust-cli/src/main.rs b/labirust-cli/src/main.rs new file mode 100644 index 0000000..389aa77 --- /dev/null +++ b/labirust-cli/src/main.rs @@ -0,0 +1,37 @@ +use std::str::FromStr; + +use clap::Parser; +use labirust::{implementations::*, Executor}; + +enum Algorithms { + DepthFirst, + BreathFirst, +} + +impl FromStr for Algorithms { + type Err = String; + + fn from_str(s: &str) -> Result { + match s { + "depth-first" => Ok(Self::DepthFirst), + "breath-first" => Ok(Self::BreathFirst), + _ => Err("No right pattern".into()), + } + } +} + +#[derive(Parser)] +struct Parameters { + algorithm_kind: Algorithms, + width: usize, + height: usize, + delay: usize, +} + +fn main() { + let params = Parameters::parse(); + + let executor = todo!(); + + println!("Hello, world!"); +} diff --git a/labirust/Cargo.toml b/labirust/Cargo.toml new file mode 100644 index 0000000..ab69e17 --- /dev/null +++ b/labirust/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "labirust" +version = "0.2.1" +edition = "2021" +license = "MIT" +authors = ["JOLIMAITRE Matthieu "] +description = "Naive rust crate for implementing and testing maze solving Algorithms." +repository = "https://github.com/MajorBarnulf/labirust/" + +[dependencies] +rand = "0.8" +termion = "1.5" diff --git a/src/algorithm.rs b/labirust/src/algorithm.rs similarity index 100% rename from src/algorithm.rs rename to labirust/src/algorithm.rs diff --git a/src/executor.rs b/labirust/src/executor.rs similarity index 96% rename from src/executor.rs rename to labirust/src/executor.rs index 9b8b42e..99b1794 100644 --- a/src/executor.rs +++ b/labirust/src/executor.rs @@ -13,7 +13,7 @@ use crate::{Algorithm, Maze, Pos}; use self::builder::{ maze_state::{BuildableMazeState, Unprovided}, - new_builder, ExecutorBuilder, + new_builder, DynExecutorBuilder, ExecutorBuilder, }; /// A guess to pass to the current [`Executor`] at the end of every `progress` call. @@ -125,6 +125,13 @@ where Self::new(maze, algorithm, delay) } + pub fn build_dyn(algorithm: A, builder: F) -> Self + where + F: Fn(DynExecutorBuilder) -> DynExecutorBuilder, + { + todo!() + } + /// Submit the maze to the [`Algorithm`] and iteratively progress through the maze driven by said algorithm. pub fn run(&mut self) { let Self { diff --git a/src/executor/builder.rs b/labirust/src/executor/builder.rs similarity index 98% rename from src/executor/builder.rs rename to labirust/src/executor/builder.rs index 58bea23..d08e862 100644 --- a/src/executor/builder.rs +++ b/labirust/src/executor/builder.rs @@ -119,3 +119,5 @@ impl ExecutorBuilder { (maze, delay) } } + +pub struct DynExecutorBuilder {} diff --git a/src/implementations.rs b/labirust/src/implementations.rs similarity index 100% rename from src/implementations.rs rename to labirust/src/implementations.rs diff --git a/src/implementations/breath_first.rs b/labirust/src/implementations/breath_first.rs similarity index 100% rename from src/implementations/breath_first.rs rename to labirust/src/implementations/breath_first.rs diff --git a/src/implementations/depth_first.rs b/labirust/src/implementations/depth_first.rs similarity index 100% rename from src/implementations/depth_first.rs rename to labirust/src/implementations/depth_first.rs diff --git a/src/labyrinth.rs b/labirust/src/labyrinth.rs similarity index 100% rename from src/labyrinth.rs rename to labirust/src/labyrinth.rs diff --git a/src/labyrinth/generator.rs b/labirust/src/labyrinth/generator.rs similarity index 100% rename from src/labyrinth/generator.rs rename to labirust/src/labyrinth/generator.rs diff --git a/src/lib.rs b/labirust/src/lib.rs similarity index 100% rename from src/lib.rs rename to labirust/src/lib.rs diff --git a/src/position.rs b/labirust/src/position.rs similarity index 100% rename from src/position.rs rename to labirust/src/position.rs