♻️ refactor: move `main` up

main
_ 2021-10-10 18:20:08 +00:00
parent e4285ec17d
commit b21f8a7c50
1 changed files with 14 additions and 14 deletions

View File

@ -10,6 +10,20 @@ enum Subcommand {
PtthQuicEndServer, PtthQuicEndServer,
} }
#[tokio::main]
async fn main () -> anyhow::Result <()> {
tracing_subscriber::fmt::init ();
let args = Vec::from_iter (std::env::args_os ());
let (subcommand, args) = parse_args (&args)?;
match subcommand {
Subcommand::PtthServer => ptth_server::executable::main (&args).await,
Subcommand::PtthFileServer => ptth_file_server::main (&args).await,
Subcommand::PtthQuicEndServer => quic_demo::executable_end_server::main (&args).await,
}
}
fn parse_subcommand (arg: &str) -> Option <Subcommand> fn parse_subcommand (arg: &str) -> Option <Subcommand>
{ {
use Subcommand::*; use Subcommand::*;
@ -58,20 +72,6 @@ fn parse_args (args: &[OsString]) -> anyhow::Result <(Subcommand, &[OsString])>
anyhow::bail! ("Subcommand must be either arg 0 (exe name) or arg 1") anyhow::bail! ("Subcommand must be either arg 0 (exe name) or arg 1")
} }
#[tokio::main]
async fn main () -> anyhow::Result <()> {
tracing_subscriber::fmt::init ();
let args = Vec::from_iter (std::env::args_os ());
let (subcommand, args) = parse_args (&args)?;
match subcommand {
Subcommand::PtthServer => ptth_server::executable::main (&args).await,
Subcommand::PtthFileServer => ptth_file_server::main (&args).await,
Subcommand::PtthQuicEndServer => quic_demo::executable_end_server::main (&args).await,
}
}
#[cfg (test)] #[cfg (test)]
mod tests { mod tests {
use super::*; use super::*;