Open db from path specified as cl arg
This commit is contained in:
parent
9b55cd1ce2
commit
ed3600a79a
2 changed files with 18 additions and 6 deletions
12
src/main.rs
12
src/main.rs
|
|
@ -1,6 +1,8 @@
|
|||
mod state;
|
||||
mod r#static;
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
use askama::Template;
|
||||
use askama_axum::{IntoResponse, Response};
|
||||
use axum::{extract::State, http::StatusCode, routing::get, Router};
|
||||
|
|
@ -20,7 +22,12 @@ const VERSION: &str = concat!(
|
|||
|
||||
#[derive(Debug, clap::Parser)]
|
||||
#[command(name = NAME, version = VERSION)]
|
||||
struct Args {}
|
||||
struct Args {
|
||||
/// Path to the repo's tablejohn database.
|
||||
db: PathBuf,
|
||||
/// Path to the git repo.
|
||||
repo: PathBuf,
|
||||
}
|
||||
|
||||
fn set_up_logging() {
|
||||
let filter = tracing_subscriber::filter::Builder::default()
|
||||
|
|
@ -47,12 +54,13 @@ async fn index(State(db): State<SqlitePool>) -> Result<Response, Response> {
|
|||
}
|
||||
|
||||
async fn run() -> anyhow::Result<()> {
|
||||
// Parse args before any logging starts
|
||||
let args = Args::parse();
|
||||
|
||||
set_up_logging();
|
||||
info!("You are running {NAME} {VERSION}");
|
||||
|
||||
let state = AppState::new().await?;
|
||||
let state = AppState::new(&args.db).await?;
|
||||
|
||||
let app = Router::new()
|
||||
.route("/", get(index))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue