refactor clap into a separate file
Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
5454b653fe
commit
3160a36634
4 changed files with 20 additions and 13 deletions
15
src/clap.rs
Normal file
15
src/clap.rs
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
//! Integration with `clap`
|
||||||
|
|
||||||
|
use clap::Parser;
|
||||||
|
|
||||||
|
/// Commandline arguments
|
||||||
|
#[derive(Parser, Debug)]
|
||||||
|
#[clap(version, about, long_about = None)]
|
||||||
|
pub struct Args {
|
||||||
|
#[arg(short, long)]
|
||||||
|
/// Optional argument to the path of a conduwuit config TOML file
|
||||||
|
pub config: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Parse commandline arguments into structured data
|
||||||
|
pub fn parse() -> Args { Args::parse() }
|
|
@ -1,4 +1,5 @@
|
||||||
pub mod api;
|
pub mod api;
|
||||||
|
pub mod clap;
|
||||||
mod config;
|
mod config;
|
||||||
mod database;
|
mod database;
|
||||||
mod service;
|
mod service;
|
||||||
|
|
11
src/main.rs
11
src/main.rs
|
@ -15,7 +15,6 @@ use axum::{
|
||||||
use axum_server::{bind, bind_rustls, tls_rustls::RustlsConfig, Handle as ServerHandle};
|
use axum_server::{bind, bind_rustls, tls_rustls::RustlsConfig, Handle as ServerHandle};
|
||||||
#[cfg(feature = "axum_dual_protocol")]
|
#[cfg(feature = "axum_dual_protocol")]
|
||||||
use axum_server_dual_protocol::ServerExt;
|
use axum_server_dual_protocol::ServerExt;
|
||||||
use clap::Parser;
|
|
||||||
use conduit::api::{client_server, server_server};
|
use conduit::api::{client_server, server_server};
|
||||||
pub use conduit::*; // Re-export everything from the library crate
|
pub use conduit::*; // Re-export everything from the library crate
|
||||||
use either::Either::{Left, Right};
|
use either::Either::{Left, Right};
|
||||||
|
@ -56,17 +55,9 @@ use tracing_subscriber::{prelude::*, EnvFilter};
|
||||||
#[global_allocator]
|
#[global_allocator]
|
||||||
static GLOBAL: Jemalloc = Jemalloc;
|
static GLOBAL: Jemalloc = Jemalloc;
|
||||||
|
|
||||||
#[derive(Parser, Debug)]
|
|
||||||
#[clap(version, about, long_about = None)]
|
|
||||||
struct Args {
|
|
||||||
#[arg(short, long)]
|
|
||||||
/// Optional argument to the path of a conduwuit config TOML file
|
|
||||||
config: Option<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
let args = Args::parse();
|
let args = clap::parse();
|
||||||
|
|
||||||
// Initialize config
|
// Initialize config
|
||||||
let raw_config = if Env::var("CONDUIT_CONFIG").is_some() {
|
let raw_config = if Env::var("CONDUIT_CONFIG").is_some() {
|
||||||
|
|
|
@ -20,14 +20,14 @@ use ruma::{
|
||||||
},
|
},
|
||||||
TimelineEventType,
|
TimelineEventType,
|
||||||
},
|
},
|
||||||
CanonicalJsonObject, CanonicalJsonValue, EventId, MxcUri, OwnedRoomAliasId, OwnedRoomId, OwnedUserId, RoomAliasId,
|
CanonicalJsonObject, EventId, MxcUri, OwnedRoomAliasId, OwnedRoomId, OwnedUserId, RoomAliasId, RoomId,
|
||||||
RoomId, RoomOrAliasId, RoomVersionId, ServerName, UserId,
|
RoomOrAliasId, RoomVersionId, ServerName, UserId,
|
||||||
};
|
};
|
||||||
use serde_json::value::to_raw_value;
|
use serde_json::value::to_raw_value;
|
||||||
use tokio::sync::{mpsc, Mutex, RwLock};
|
use tokio::sync::{mpsc, Mutex, RwLock};
|
||||||
use tracing::{debug, error, info, warn};
|
use tracing::{debug, error, info, warn};
|
||||||
|
|
||||||
use super::pdu::{self, PduBuilder};
|
use super::pdu::PduBuilder;
|
||||||
use crate::{
|
use crate::{
|
||||||
api::client_server::{get_alias_helper, leave_all_rooms, leave_room, AUTO_GEN_PASSWORD_LENGTH},
|
api::client_server::{get_alias_helper, leave_all_rooms, leave_room, AUTO_GEN_PASSWORD_LENGTH},
|
||||||
services,
|
services,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue