set up structure for multiple cli commands

The previous cli is now behind the 'serve' subcommand.
This commit is contained in:
Benjamin Lee 2024-08-31 20:51:26 -07:00
parent 1ee3bbb316
commit be87774a3b
No known key found for this signature in database
GPG key ID: FB9624E2885D55A4
4 changed files with 60 additions and 39 deletions

View file

@ -19,6 +19,7 @@ use axum::{
use axum_server::{
bind, bind_rustls, tls_rustls::RustlsConfig, Handle as ServerHandle,
};
use clap::Parser;
use futures_util::FutureExt;
use http::{
header::{self, HeaderName},
@ -41,7 +42,7 @@ use tower_http::{
use tracing::{debug, error, info, info_span, warn, Instrument};
mod api;
mod args;
mod cli;
mod config;
mod database;
mod error;
@ -51,6 +52,7 @@ mod utils;
pub(crate) use api::ruma_wrapper::{Ar, Ra};
use api::{client_server, server_server, well_known};
use cli::{Args, Command};
pub(crate) use config::{Config, ListenConfig};
pub(crate) use database::KeyValueDatabase;
pub(crate) use service::{pdu::PduEvent, Services};
@ -108,9 +110,12 @@ async fn main() -> ExitCode {
async fn try_main() -> Result<(), error::Main> {
use error::Main as Error;
let args = args::parse();
let args = Args::parse();
// This is a placeholder, the logic specific to the 'serve' command will be
// moved to another file in a later commit
let Command::Serve(args) = args.command;
let config = config::load(args.config.as_ref()).await?;
let config = config::load(args.config.config.as_ref()).await?;
let (_guard, reload_handles) = observability::init(&config)?;