mcst/src/main.rs
Gregory Ballantine da099a11ce
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Added the 'new' command which creates the scaffolding for a server instance
2022-09-19 16:57:10 -04:00

39 lines
1.1 KiB
Rust

mod cmd;
use clap::{Parser, Subcommand};
#[derive(Parser)]
#[clap(name = "Minecraft server management tool", author, version, about = "Bit Goblin's Minecraft server management tool.", long_about = None)]
#[clap(propagate_version = true)]
struct Cli {
#[clap(subcommand)]
command: Commands,
}
#[derive(Subcommand)]
enum Commands {
// new server subcommand
#[clap(name = "new", about = "Create a new Minecraft java edition server instance.")]
New {
#[clap(short = 'n', long, required = true, help = "[REQUIRED] The name for your new server")]
server_name: String,
#[clap(short = 'm', long, required = true, help = "[REQUIRED] Minecraft Java Edition server version to use.")]
minecraft_version: String,
},
}
fn main() {
// start the Clap CLI
let cli = Cli::parse();
// map subcommands back to the main command
let res = match &cli.command {
Commands::New { server_name, minecraft_version } => cmd::new::new_command(&server_name, &minecraft_version),
};
match res {
Ok(_) => {},
Err(e) => panic!("MCST ran into an error: {}", e),
};
}