Skip to content

Commit

Permalink
add check for properly initialized lockfile
Browse files Browse the repository at this point in the history
  • Loading branch information
dxbednarczyk committed Feb 8, 2024
1 parent fecae12 commit 8556799
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/server/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
use anyhow::anyhow;
use clap::Subcommand;

mod eula;
pub mod lockfile;

use lockfile::Lockfile;

#[derive(Debug, Subcommand)]
pub enum Server {
/// Initialize a server in the current directory
Expand All @@ -25,10 +28,18 @@ pub fn action(server: &Server) -> Result<(), anyhow::Error> {
Server::Init {
minecraft_version,
loader,
} => {
lockfile::Lockfile::with_params(minecraft_version, loader)?;
Ok(())
}
} => init(minecraft_version, loader),
Server::Sign => eula::sign(),
}
}

fn init(minecraft_version: &str, loader: &str) -> Result<(), anyhow::Error> {
let mut lf = Lockfile::with_params(minecraft_version, loader)?;
if !lf.is_initialized() {
return Err(anyhow!(
"lockfile was initialized with invalid configuration"
));
}

Ok(())
}

0 comments on commit 8556799

Please sign in to comment.