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)]
|
#[derive(Args, Debug)]
|
||||||
pub struct InitArgs {
|
pub enum Command {
|
||||||
#[arg(short = "d")]
|
Add(AddArgs),
|
||||||
pub dir: Option<String>,
|
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")]
|
#[arg(short = "f")]
|
||||||
pub template: Option<String>,
|
pub hopfiles: Vec<String>,
|
||||||
|
|
||||||
#[arg(short = "m")]
|
pub package_names: Vec<String>,
|
||||||
pub mc_version: Vec<String>,
|
|
||||||
|
|
||||||
#[arg(short = "t", required)]
|
|
||||||
pub package_type: PackageType,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Args, Debug)]
|
#[derive(Args, Debug)]
|
||||||
pub struct HopArgs {
|
pub struct HopArgs {
|
||||||
#[arg(short = "f")]
|
#[arg(short = "f")]
|
||||||
pub hopfile: Option<String>,
|
pub hopfile: Vec<String>,
|
||||||
|
|
||||||
#[arg(short = "m")]
|
#[arg(short = "m")]
|
||||||
pub mc_version: Vec<String>,
|
pub mc_version: Vec<String>,
|
||||||
|
@ -63,9 +69,32 @@ pub struct HopArgs {
|
||||||
pub package_type: Option<PackageType>,
|
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)]
|
#[derive(Args, Debug)]
|
||||||
pub struct SearchArgs {
|
pub struct SearchArgs {
|
||||||
pub package_name: String,
|
#[arg(short = "n")]
|
||||||
|
pub no_confirm: bool,
|
||||||
|
|
||||||
/// Overrides the download directory
|
/// Overrides the download directory
|
||||||
#[arg(short = "d")]
|
#[arg(short = "d")]
|
||||||
|
@ -77,34 +106,14 @@ pub struct SearchArgs {
|
||||||
|
|
||||||
/// Type of package to use
|
/// Type of package to use
|
||||||
#[arg(short = "t")]
|
#[arg(short = "t")]
|
||||||
pub package_type: Option<PackageType>,
|
pub package_type: PackageType,
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Args, Debug)]
|
pub package_name: String,
|
||||||
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"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
pub enum PackageType {
|
pub enum PackageType {
|
||||||
|
Dummy,
|
||||||
Mod(Loader),
|
Mod(Loader),
|
||||||
Pack(Loader),
|
Pack(Loader),
|
||||||
Plugin(Server),
|
Plugin(Server),
|
||||||
|
@ -127,11 +136,30 @@ pub enum Server {
|
||||||
Sponge,
|
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)]
|
#[derive(Clone, Debug)]
|
||||||
pub enum PackageParseError {
|
pub enum PackageParseError {
|
||||||
Invalid(String),
|
Invalid(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl std::default::Default for PackageType { //TODO: Actually implement Default
|
||||||
|
fn default() -> Self { // for PackageType
|
||||||
|
PackageType::Dummy
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl FromStr for PackageType {
|
impl FromStr for PackageType {
|
||||||
type Err = PackageParseError;
|
type Err = PackageParseError;
|
||||||
fn from_str(s: &str) -> Result<PackageType, PackageParseError> {
|
fn from_str(s: &str) -> Result<PackageType, PackageParseError> {
|
||||||
|
|
|
@ -81,8 +81,9 @@ impl HopperClient {
|
||||||
.join(",");
|
.join(",");
|
||||||
facets.push(format!("{}", versions_facets));
|
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 {
|
let project_type = match package_type {
|
||||||
|
PackageType::Dummy => "",
|
||||||
PackageType::Mod(_) => "[\"project_type:mod\"]",
|
PackageType::Mod(_) => "[\"project_type:mod\"]",
|
||||||
PackageType::Pack(_) => "[\"project_type:modpack\"]",
|
PackageType::Pack(_) => "[\"project_type:modpack\"]",
|
||||||
PackageType::Plugin(_) => "[\"project_type:mod\"]",
|
PackageType::Plugin(_) => "[\"project_type:mod\"]",
|
||||||
|
@ -90,6 +91,7 @@ impl HopperClient {
|
||||||
};
|
};
|
||||||
|
|
||||||
let project_category = match package_type {
|
let project_category = match package_type {
|
||||||
|
PackageType::Dummy => "",
|
||||||
PackageType::Mod(kind) | PackageType::Pack(kind) => {
|
PackageType::Mod(kind) | PackageType::Pack(kind) => {
|
||||||
match kind {
|
match kind {
|
||||||
Loader::Fabric => "[\"categories:fabric\"]",
|
Loader::Fabric => "[\"categories:fabric\"]",
|
||||||
|
|
Loading…
Reference in New Issue