From f6a6d190efd9b61ae263a238758c0bcbd45c4a47 Mon Sep 17 00:00:00 2001 From: Titouan Rigoudy Date: Fri, 16 Jul 2021 19:02:22 -0400 Subject: [PATCH] Add --async command line switch. --- Cargo.lock | 52 ++++++++++++++++++++++++++++++++++++++++++++++ client/Cargo.toml | 1 + client/src/main.rs | 29 +++++++++++++++++++++++--- 3 files changed, 79 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 254659a..5dbe65d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11,6 +11,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "ansi_term" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" +dependencies = [ + "winapi 0.3.9", +] + [[package]] name = "async-stream" version = "0.3.2" @@ -113,6 +122,21 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "clap" +version = "2.33.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" +dependencies = [ + "ansi_term", + "atty", + "bitflags 1.2.1", + "strsim", + "textwrap", + "unicode-width", + "vec_map", +] + [[package]] name = "cloudabi" version = "0.0.3" @@ -1098,6 +1122,7 @@ checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" name = "solstice-client" version = "0.1.0" dependencies = [ + "clap", "crossbeam-channel", "env_logger", "log 0.4.14", @@ -1139,6 +1164,12 @@ dependencies = [ "tokio-io", ] +[[package]] +name = "strsim" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" + [[package]] name = "syn" version = "1.0.73" @@ -1159,6 +1190,15 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "textwrap" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" +dependencies = [ + "unicode-width", +] + [[package]] name = "thiserror" version = "1.0.26" @@ -1464,6 +1504,12 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "unicode-width" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" + [[package]] name = "unicode-xid" version = "0.2.2" @@ -1481,6 +1527,12 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "vec_map" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" + [[package]] name = "wasi" version = "0.10.0+wasi-snapshot-preview1" diff --git a/client/Cargo.toml b/client/Cargo.toml index a86c6ee..98c390c 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -5,6 +5,7 @@ authors = ["letitz"] edition = "2018" [dependencies] +clap = "^2.33" crossbeam-channel = "^0.3" env_logger = "^0.8" log = "^0.4" diff --git a/client/src/main.rs b/client/src/main.rs index e968053..75d41ad 100644 --- a/client/src/main.rs +++ b/client/src/main.rs @@ -4,6 +4,7 @@ extern crate log; use std::thread; +use clap::{App, Arg}; use crossbeam_channel; use env_logger; use solstice_proto; @@ -24,9 +25,7 @@ mod message_handler; mod room; mod user; -fn main() { - env_logger::init(); - +fn old_main() { let (proto_to_client_tx, proto_to_client_rx) = crossbeam_channel::unbounded(); let mut proto_agent = match solstice_proto::Agent::new(proto_to_client_tx) { @@ -51,3 +50,27 @@ fn main() { thread::spawn(move || proto_agent.run().unwrap()); client.run(); } + +fn async_main() { + // TODO +} + +fn main() { + env_logger::init(); + + let matches = App::new("solstice-client") + .version("0.1") + .author("letitz") + .arg( + Arg::with_name("async") + .long("async") + .help("Use the new async engine."), + ) + .get_matches(); + + if matches.is_present("async") { + async_main(); + } else { + old_main(); + } +}