diff --git a/.gitignore b/.gitignore index adf8f72..193d30e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,23 +1,21 @@ -# ---> Go -# If you prefer the allow list template instead of the deny list, see community template: -# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore -# -# Binaries for programs and plugins -*.exe -*.exe~ -*.dll -*.so -*.dylib +# ---> Rust +# Generated by Cargo +# will have compiled files and executables +debug/ +target/ -# Test binary, built with `go test -c` -*.test +# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries +# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html +Cargo.lock -# Output of the go coverage tool, specifically when used with LiteIDE -*.out +# These are backup files generated by rustfmt +**/*.rs.bk -# Dependency directories (remove the comment below to include it) -# vendor/ +# MSVC Windows builds of rustc generate these, which store debugging information +*.pdb -# Go workspace file -go.work + +# Added by cargo + +/target diff --git a/.woodpecker.yml b/.woodpecker.yml new file mode 100644 index 0000000..e07435a --- /dev/null +++ b/.woodpecker.yml @@ -0,0 +1,30 @@ +pipeline: + tests: + image: rust:1.63 + commands: + - "cargo test" + + build_release: + image: rust:1.63 + commands: + - "cargo install cargo-deb cargo-generate-rpm" + - "cargo build --release" + - "cargo deb" + - "cargo generate-rpm" + - "mv target/release/mcst target/release/mcst-${CI_COMMIT_TAG}-linux-x86_64" + when: + event: tag + + gitea_release: + image: plugins/gitea-release + settings: + api_key: + from_secret: gitea_api_key + base_url: https://git.metaunix.net + files: + - "target/release/*${CI_COMMIT_TAG}-linux-x86_64" + - "target/debian/mcst*.deb" + - "target/generate-rpm/mcst*.rpm" + title: "${CI_COMMIT_TAG}" + when: + event: tag diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..b619460 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "mcst" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +clap = { version = "3.2", features = ["derive"] } diff --git a/LICENSE b/LICENSE index 5f662b3..2b5518f 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) +Copyright (c) 2022 Bit Goblin Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/src/cmd/mod.rs b/src/cmd/mod.rs new file mode 100644 index 0000000..9d52a2b --- /dev/null +++ b/src/cmd/mod.rs @@ -0,0 +1 @@ +pub mod new; diff --git a/src/cmd/new.rs b/src/cmd/new.rs new file mode 100644 index 0000000..c206359 --- /dev/null +++ b/src/cmd/new.rs @@ -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); +} diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..5c83a7d --- /dev/null +++ b/src/main.rs @@ -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), + } +}