Skip to content

Commit

Permalink
added help/versions args
Browse files Browse the repository at this point in the history
  • Loading branch information
babymotte committed Jun 27, 2022
1 parent 690329b commit f98be20
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions worterbuch/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ anyhow = "1.0.57"
serde = { version = "1.0.137", features = ["derive"] }
serde_json = "1.0.81"
uuid = { version = "1.1.1", features = ["v4"] }
clap = "3.2.6"

juniper = { version = "0.15.9", optional = true }
juniper_graphql_ws = { version = "0.3.0", optional = true }
Expand Down
16 changes: 11 additions & 5 deletions worterbuch/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ mod worterbuch;
use crate::repl::repl;
use crate::worterbuch::Worterbuch;
use anyhow::Result;
use clap::App;
use libworterbuch::config::Config;
use std::sync::Arc;
#[cfg(feature = "docker")]
Expand All @@ -20,22 +21,27 @@ use tokio::{spawn, sync::RwLock};
async fn main() -> Result<()> {
dotenv::dotenv().ok();
env_logger::init();
log::info!("Starting single-threaded instance of Wörterbuch …");
run().await
run("Starting Wörterbuch in single-threaded mode …").await
}

#[cfg(feature = "multithreaded")]
#[tokio::main]
async fn main() -> Result<()> {
dotenv::dotenv().ok();
env_logger::init();
log::info!("Starting multi-threaded instance of Wörterbuch …");
run().await
run("Starting Wörterbuch in multi-threaded mode …").await
}

async fn run() -> Result<()> {
async fn run(msg: &str) -> Result<()> {
let config = Config::new()?;

App::new("worterbuch")
.version(env!("CARGO_PKG_VERSION"))
.author(env!("CARGO_PKG_AUTHORS"))
.about("An in-memory data base / message broker hybrid")
.get_matches();

log::info!("{msg}");
log::debug!("Separator: {}", config.separator);
log::debug!("Wildcard: {}", config.wildcard);
log::debug!("Multi-Wildcard: {}", config.multi_wildcard);
Expand Down
2 changes: 1 addition & 1 deletion worterbuch/src/repl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub async fn repl(worterbuch: Arc<RwLock<Worterbuch>>) {
let (tx, mut rx) = unbounded_channel();
thread::spawn(|| read(tx));

log::info!("Starting REPL:");
log::info!("Starting REPL");

while let Some(line) = rx.recv().await {
if let Err(e) = interpret(line, &worterbuch).await {
Expand Down

0 comments on commit f98be20

Please sign in to comment.