Skip to content

Commit

Permalink
refactor: remove dead code and rename some stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
arexon committed Sep 24, 2024
1 parent 5578ba3 commit a8e4445
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
19 changes: 5 additions & 14 deletions src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use anstyle::{AnsiColor, Color, Style};
use clap::{builder, Parser, Subcommand};

#[cfg(windows)]
use clap::ValueEnum;
use clap::{builder, Parser, Subcommand};

#[cfg(windows)]
use crate::com_mojang::MinecraftVersion;
Expand All @@ -18,7 +17,7 @@ pub struct Cli {
/// an arbitrary path, set the `COM_MOJANG` environment variable instead
#[cfg(windows)]
#[arg(short = 'm', long, value_enum, default_value = "stable")]
pub minecraft_version: MinecraftVersionWrapper,
pub minecraft_version: MinecraftVersion,

#[command(subcommand)]
pub commands: Commands,
Expand Down Expand Up @@ -51,21 +50,13 @@ pub enum Commands {
}

#[cfg(windows)]
#[derive(Clone)]
pub struct MinecraftVersionWrapper(pub MinecraftVersion);

#[cfg(windows)]
impl ValueEnum for MinecraftVersionWrapper {
impl ValueEnum for MinecraftVersion {
fn value_variants<'a>() -> &'a [Self] {
&[
Self(MinecraftVersion::Stable),
Self(MinecraftVersion::Preview),
Self(MinecraftVersion::Education),
]
&[Self::Stable, Self::Preview, Self::Education]
}

fn to_possible_value(&self) -> Option<builder::PossibleValue> {
Some(builder::PossibleValue::new(self.0.as_str()))
Some(builder::PossibleValue::new(self.as_str()))
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ fn main() {
#[cfg(windows)]
let com_mojang = com_mojang::get_and_check(&cli.minecraft_version.0)?;

let haze = WorldManager::new(config.worlds, com_mojang)?;
let wm = WorldManager::new(config.worlds, com_mojang)?;
match cli.commands {
Commands::Export { names, overwrite } => haze.export(names, overwrite)?,
Commands::Import { names } => haze.import(names)?,
Commands::List => haze.list()?,
Commands::Export { names, overwrite } => wm.export(names, overwrite)?,
Commands::Import { names } => wm.import(names)?,
Commands::List => wm.list()?,
}

Ok(())
Expand Down

0 comments on commit a8e4445

Please sign in to comment.