diff --git a/Cargo.toml b/Cargo.toml index 7622ee67..b3c3236e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,3 +4,6 @@ members = [ "src/cpp", "src/rs", ] +default-members = [ + "src/rs" +] diff --git a/Makefile b/Makefile index 644c73ab..4f9ccd3b 100644 --- a/Makefile +++ b/Makefile @@ -37,21 +37,19 @@ test-rs-all: \ test-rs-orientation_packer \ test-rs-no_orientation_mod -TEST_RS = cargo test --package twsearch - .PHONY: test-rs-default test-rs-default: - ${TEST_RS} + cargo test .PHONY: test-rs-orientation_packer test-rs-orientation_packer: - ${TEST_RS} --features orientation_packer + cargo test --features orientation_packer .PHONY: test-rs-no_orientation_mod test-rs-no_orientation_mod: - ${TEST_RS} --features no_orientation_mod + cargo test --features no_orientation_mod -BENCHMARK_RS = cargo run --package twsearch --release --example benchmark +BENCHMARK_RS = cargo run --release --example benchmark .PHONY: benchmark-rs-all benchmark-rs-all: \ diff --git a/src/cpp/examples/lib/common.rs b/src/cpp/examples/lib/common.rs index 26f09ed3..b076ff90 100644 --- a/src/cpp/examples/lib/common.rs +++ b/src/cpp/examples/lib/common.rs @@ -42,6 +42,8 @@ impl CliCommand { CliCommand::Cpp() => &[], CliCommand::Rust() => &[ "run", + "--package", + "twsearch-cpp-wrapper", "--quiet", // Suppress deprecation warnings for transitive dependencies (`buf_redux`, `multipart`): https://github.com/tomaka/rouille/issues/271 "--", "search", diff --git a/src/rs/Cargo.toml b/src/rs/Cargo.toml index a14e06e1..66577789 100644 --- a/src/rs/Cargo.toml +++ b/src/rs/Cargo.toml @@ -10,14 +10,18 @@ no_orientation_mod = [] [dependencies] cityhash = "0.1.1" -clap = "4.3.24" +clap = { version = "4.3.24", features = ["derive"] } clap_complete = "4.3.2" cubing = "0.5.4" derive_more = "0.99.17" -serde = "1.0.186" +serde = { version = "1.0.186", features = ["derive", "rc"] } [dev-dependencies] wait-timeout = "0.2.0" [lib] path = "./mod.rs" + +[[bin]] +name = "twsearch" +path = "./cli/main.rs" diff --git a/src/rs/cli/main.rs b/src/rs/cli/main.rs new file mode 100644 index 00000000..c1015db9 --- /dev/null +++ b/src/rs/cli/main.rs @@ -0,0 +1,27 @@ +use std::process::exit; + +use twsearch::_internal::cli::{get_options_cpp_wrapper, CliCommand}; + +fn main() { + let args = get_options_cpp_wrapper(); + + let result: Result<(), String> = match args.command { + CliCommand::Completions(_completions_args) => { + panic!("Completions should have been printed during options parsing, followed by program exit."); + } + CliCommand::Search(_search_command_args) => todo!(), + CliCommand::Serve(_serve_command_args) => { + eprintln!("Skipping `serve` command."); + Ok(()) + } + // TODO: consolidate def-only arg implementations. + CliCommand::SchreierSims(_schreier_sims_command_args) => todo!(), + CliCommand::GodsAlgorithm(_gods_algorithm_args) => todo!(), + CliCommand::TimingTest(_args) => todo!(), + CliCommand::CanonicalAlgs(_args) => todo!(), + }; + if let Err(err) = result { + eprintln!("{}", err); + exit(1); + } +}