2025-06-01 16:29:35 +09:00
|
|
|
use clap::{Parser, Subcommand};
|
2025-06-07 09:28:18 +09:00
|
|
|
use lazy_supplements::{cli::{ConfigArgs, ConsoleArgs, ConsoleCommands, InitArgs, NodeArgs, NodeCommand, ServerArgs}, global::{Global, GLOBAL}, *};
|
2025-06-01 16:29:35 +09:00
|
|
|
|
|
|
|
#[derive(Debug, Parser)]
|
|
|
|
struct Cli {
|
|
|
|
#[command(subcommand)]
|
|
|
|
command: Command,
|
2025-06-07 09:28:18 +09:00
|
|
|
#[command(flatten)]
|
|
|
|
pub config: ConfigArgs,
|
2025-06-01 16:29:35 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Subcommand)]
|
|
|
|
enum Command {
|
2025-06-05 09:23:24 +09:00
|
|
|
Console(ConsoleArgs),
|
2025-06-01 16:29:35 +09:00
|
|
|
Node(NodeArgs),
|
|
|
|
Init(InitArgs),
|
2025-06-02 12:02:04 +09:00
|
|
|
Server(ServerArgs),
|
2025-06-01 16:29:35 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[tokio::main]
|
|
|
|
async fn main() {
|
2025-06-07 09:28:18 +09:00
|
|
|
let cli = Cli::parse();
|
|
|
|
let _ = GLOBAL.get_or_init_node_config(cli.config.try_into_node_config().await.unwrap()).await;
|
|
|
|
match cli.command {
|
|
|
|
Command::Node(x) => x.run().await.unwrap(),
|
2025-06-01 16:29:35 +09:00
|
|
|
Command::Init(x) => x.init_config().await,
|
2025-06-02 12:02:04 +09:00
|
|
|
Command::Server(x) => x.start_server().await.unwrap(),
|
2025-06-06 06:50:28 +09:00
|
|
|
Command::Console(x) => x.start_console(ConsoleCommands::default()).await.unwrap(),
|
2025-06-01 16:29:35 +09:00
|
|
|
}
|
|
|
|
}
|