args.rs, client.rs: changed to reflect changes to usage text
This commit is contained in:
parent
b01064e615
commit
0f1561e0c4
96
src/args.rs
96
src/args.rs
|
@ -37,24 +37,30 @@ pub struct Arguments {
|
|||
}
|
||||
|
||||
#[derive(Args, Debug)]
|
||||
pub struct InitArgs {
|
||||
#[arg(short = "d")]
|
||||
pub dir: Option<String>,
|
||||
pub enum Command {
|
||||
Add(AddArgs),
|
||||
Get(SearchArgs),
|
||||
Init(InitArgs),
|
||||
List(HopArgs),
|
||||
Remove(RmArgs),
|
||||
Update(HopArgs),
|
||||
}
|
||||
|
||||
#[derive(Args, Debug)]
|
||||
pub struct AddArgs {
|
||||
#[arg(short = "m")]
|
||||
pub mc_version: String,
|
||||
|
||||
#[arg(short = "f")]
|
||||
pub template: Option<String>,
|
||||
pub hopfiles: Vec<String>,
|
||||
|
||||
#[arg(short = "m")]
|
||||
pub mc_version: Vec<String>,
|
||||
|
||||
#[arg(short = "t", required)]
|
||||
pub package_type: PackageType,
|
||||
pub package_names: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Args, Debug)]
|
||||
pub struct HopArgs {
|
||||
#[arg(short = "f")]
|
||||
pub hopfile: Option<String>,
|
||||
pub hopfile: Vec<String>,
|
||||
|
||||
#[arg(short = "m")]
|
||||
pub mc_version: Vec<String>,
|
||||
|
@ -63,9 +69,32 @@ pub struct HopArgs {
|
|||
pub package_type: Option<PackageType>,
|
||||
}
|
||||
|
||||
#[derive(Args, Debug)]
|
||||
pub struct InitArgs {
|
||||
#[arg(short = "f")]
|
||||
pub template: Option<String>,
|
||||
|
||||
pub mc_version: String,
|
||||
|
||||
pub package_type: PackageType,
|
||||
}
|
||||
|
||||
#[derive(Args, Debug)]
|
||||
pub struct RmArgs {
|
||||
#[arg(short = "f")]
|
||||
pub hopfile: Option<String>,
|
||||
|
||||
pub package_type: PackageType,
|
||||
|
||||
pub mc_version: String,
|
||||
|
||||
pub package_names: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Args, Debug)]
|
||||
pub struct SearchArgs {
|
||||
pub package_name: String,
|
||||
#[arg(short = "n")]
|
||||
pub no_confirm: bool,
|
||||
|
||||
/// Overrides the download directory
|
||||
#[arg(short = "d")]
|
||||
|
@ -77,34 +106,14 @@ pub struct SearchArgs {
|
|||
|
||||
/// Type of package to use
|
||||
#[arg(short = "t")]
|
||||
pub package_type: Option<PackageType>,
|
||||
}
|
||||
pub package_type: PackageType,
|
||||
|
||||
#[derive(Args, Debug)]
|
||||
pub enum Command {
|
||||
Add(SearchArgs),
|
||||
Get(SearchArgs),
|
||||
Init(InitArgs),
|
||||
List(HopArgs),
|
||||
Remove(HopArgs),
|
||||
Update(HopArgs),
|
||||
}
|
||||
|
||||
impl fmt::Display for Command {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match &self {
|
||||
Command::Add(_) => write!(f, "add"),
|
||||
Command::Get(_) => write!(f, "get"),
|
||||
Command::Init(_) => write!(f, "init"),
|
||||
Command::List(_) => write!(f, "list"),
|
||||
Command::Remove(_) => write!(f, "remove"),
|
||||
Command::Update(_) => write!(f, "update"),
|
||||
}
|
||||
}
|
||||
pub package_name: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub enum PackageType {
|
||||
Dummy,
|
||||
Mod(Loader),
|
||||
Pack(Loader),
|
||||
Plugin(Server),
|
||||
|
@ -127,11 +136,30 @@ pub enum Server {
|
|||
Sponge,
|
||||
}
|
||||
|
||||
impl fmt::Display for Command {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match &self {
|
||||
Command::Add(_) => write!(f, "add"),
|
||||
Command::Get(_) => write!(f, "get"),
|
||||
Command::Init(_) => write!(f, "init"),
|
||||
Command::List(_) => write!(f, "list"),
|
||||
Command::Remove(_) => write!(f, "remove"),
|
||||
Command::Update(_) => write!(f, "update"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum PackageParseError {
|
||||
Invalid(String),
|
||||
}
|
||||
|
||||
impl std::default::Default for PackageType { //TODO: Actually implement Default
|
||||
fn default() -> Self { // for PackageType
|
||||
PackageType::Dummy
|
||||
}
|
||||
}
|
||||
|
||||
impl FromStr for PackageType {
|
||||
type Err = PackageParseError;
|
||||
fn from_str(s: &str) -> Result<PackageType, PackageParseError> {
|
||||
|
|
|
@ -81,8 +81,9 @@ impl HopperClient {
|
|||
.join(",");
|
||||
facets.push(format!("{}", versions_facets));
|
||||
}
|
||||
if let Some(package_type) = search_args.package_type {
|
||||
if let package_type = search_args.package_type {
|
||||
let project_type = match package_type {
|
||||
PackageType::Dummy => "",
|
||||
PackageType::Mod(_) => "[\"project_type:mod\"]",
|
||||
PackageType::Pack(_) => "[\"project_type:modpack\"]",
|
||||
PackageType::Plugin(_) => "[\"project_type:mod\"]",
|
||||
|
@ -90,6 +91,7 @@ impl HopperClient {
|
|||
};
|
||||
|
||||
let project_category = match package_type {
|
||||
PackageType::Dummy => "",
|
||||
PackageType::Mod(kind) | PackageType::Pack(kind) => {
|
||||
match kind {
|
||||
Loader::Fabric => "[\"categories:fabric\"]",
|
||||
|
|
Loading…
Reference in New Issue