Skip to content

Commit

Permalink
Merge pull request #82 from lordofwizard/feature-arg
Browse files Browse the repository at this point in the history
Added new files with their impls and a basic test that checks few thi…
  • Loading branch information
lordofwizard authored Oct 16, 2024
2 parents 96146f8 + 2114a9a commit 2ae1a69
Show file tree
Hide file tree
Showing 8 changed files with 298 additions and 1 deletion.
230 changes: 230 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
clap = { version = "4.5.20", features = ["derive"] }
31 changes: 31 additions & 0 deletions src/args.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
use clap::{Parser, Subcommand};

#[derive(Debug, Parser)]
#[clap(
name = "MCServer",
about = "MCServer a cli utility created to host a Fully Customizable Minecraft Server",
author = "LordOfWizard",
version = "0.0.1"
)]
pub struct MCServer {
#[clap(subcommand)]
pub command: Commands,
}

#[derive(Debug, Subcommand)]
pub enum Commands {
/// Generates a new Minecraft Server instance.
Setup,
/// Builds a new Minecraft Server Instance.
Build,
/// Starts the Minecraft Server.
Start,
/// Stops the Minecraft Server.
Stop,
/// Prints the logs of the latest run.
Log,
/// Gives debug information on Currently running server.
Check,
/// Prints the connectable url of the Minecraft Server.
GetUrl,
}
3 changes: 3 additions & 0 deletions src/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub fn build() {
// TODO Build this
}
4 changes: 4 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
mod run;
mod args;
mod start;
mod build;
mod setup;
use run::Run;
fn main() {
println!("Hello, world!");
Expand Down
24 changes: 23 additions & 1 deletion src/run.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
pub struct Run;
use clap::Parser;
use crate::args::{MCServer,Commands};
use crate::build::build;
use crate::setup::setup;
use crate::start::start_server;


impl Run {
pub fn new() {
// TODO this is where the program should start
println!("Program Started");

let server_instance = MCServer::parse();

match server_instance.command {
Commands::Setup => setup(),
Commands::Build => build(),
Commands::Start => start_server(),

_ => println!("Nah didn't reach me bruh"),
}

}
}

Expand All @@ -13,7 +30,12 @@ mod tests {

#[test]
fn run_has_std_practices() {
Run::new();
//Run::new();
assert!(true);
}
#[test]
fn setup_available() {
setup();
assert!(true);
}
}
3 changes: 3 additions & 0 deletions src/setup.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub fn setup(){
// TODO Build this
}
3 changes: 3 additions & 0 deletions src/start.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub fn start_server(){
// TODO Build this
}

0 comments on commit 2ae1a69

Please sign in to comment.