zero-trust-rps 0.0.5

Online Multiplayer Rock Paper Scissors
Documentation
mod cli_utils;
mod client;
mod common;
mod server;

use clap::{Parser, Subcommand};
use cli_utils::{print_error, run, CLAP_LONG_VERSION};
use client::ClientOptions;
use common::constants::CRATE_VERSION;
use server::ServerOptions;

#[derive(Parser)]
#[command(about, long_about = None)]
#[command(propagate_version = true)]
#[command(long_version = CLAP_LONG_VERSION, version = CRATE_VERSION)]
struct Cli {
    #[command(subcommand)]
    command: Commands,
}

#[derive(Subcommand)]
enum Commands {
    Server(ServerOptions),
    Client(ClientOptions),
}

fn main() -> std::process::ExitCode {
    let cli = Cli::parse();

    match &cli.command {
        Commands::Server(opts) => {
            print_error::<false, _>(run(server::server_main(module_path!(), opts)))
        }
        Commands::Client(opts) => {
            print_error::<true, _>(run(client::client_main(module_path!(), opts)))
        }
    }
}