aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoris2023-01-28 09:47:51 +0100
committerJoris2023-01-28 09:47:51 +0100
commit75d96e813dbe48eda89321adccadccd40d9fbafa (patch)
tree6b6260b56ab731f02be52561d58e958a7949e27d /src
parentc2e4f36b84137854c35e2c455924b936b090a284 (diff)
Upgrade dependencies
Diffstat (limited to 'src')
-rw-r--r--src/main.rs26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/main.rs b/src/main.rs
index 2371644..99c20a3 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,9 +1,9 @@
+use clap::Parser;
use hyper::service::{make_service_fn, service_fn};
use hyper::Server;
use sqlx::sqlite::SqlitePool;
use std::convert::Infallible;
use std::net::SocketAddr;
-use structopt::StructOpt;
#[macro_use]
extern crate log;
@@ -23,16 +23,16 @@ mod validation;
use model::config::Config;
-#[derive(StructOpt)]
-#[structopt()]
-struct Opt {
- #[structopt(short, long, default_value = "0.0.0.0:3000")]
+#[derive(Parser)]
+#[clap()]
+struct Args {
+ #[clap(short, long, default_value = "0.0.0.0:3000")]
address: SocketAddr,
- #[structopt(short, long, default_value = "config.json")]
+ #[clap(short, long, default_value = "config.json")]
config: String,
- #[structopt(short, long, default_value = "database.db")]
+ #[clap(short, long, default_value = "database.db")]
database: String,
}
@@ -43,13 +43,13 @@ async fn main() {
)
.init();
- let opt = Opt::from_args();
+ let args = Args::parse();
- let config_str = std::fs::read_to_string(&opt.config)
- .expect(&format!("Missing {}", opt.config));
+ let config_str = std::fs::read_to_string(&args.config)
+ .expect(&format!("Missing {}", args.config));
let config: Config = serde_json::from_str(&config_str).unwrap();
- let pool = SqlitePool::connect(&format!("sqlite:{}", opt.database))
+ let pool = SqlitePool::connect(&format!("sqlite:{}", args.database))
.await
.unwrap();
@@ -81,8 +81,8 @@ async fn main() {
}
});
- info!("Starting server at {}", opt.address);
- if let Err(e) = Server::bind(&opt.address).serve(make_svc).await {
+ info!("Starting server at {}", args.address);
+ if let Err(e) = Server::bind(&args.address).serve(make_svc).await {
error!("server error: {}", e);
}
}