Initial rust project structure with clap
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
2022-09-19 15:33:34 -04:00
parent 26a7ab742e
commit 1723c26ba9
7 changed files with 93 additions and 19 deletions

1
src/cmd/mod.rs Normal file
View File

@ -0,0 +1 @@
pub mod new;

3
src/cmd/new.rs Normal file
View File

@ -0,0 +1,3 @@
pub fn new_command(server_name: &str, minecraft_version: &str) {
println!("Creating new server with name '{}' using version '{}'.", server_name, minecraft_version);
}

33
src/main.rs Normal file
View File

@ -0,0 +1,33 @@
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
match &cli.command {
Commands::New { server_name, minecraft_version } => cmd::new::new_command(&server_name, &minecraft_version),
}
}