forked from minecrust/hopper
Refactor a little bit
This commit is contained in:
parent
a93559e17b
commit
d7bd53a7a9
14
README.md
14
README.md
|
@ -2,12 +2,19 @@
|
||||||
|
|
||||||
- modrinth mod searching
|
- modrinth mod searching
|
||||||
- modrinth mod installation
|
- modrinth mod installation
|
||||||
|
- curseforge api too?
|
||||||
- per-instance mod management
|
- per-instance mod management
|
||||||
- mod updating
|
- mod updating
|
||||||
|
- fish autocomplete
|
||||||
|
- bash autocomplete
|
||||||
|
- zsh autocomplete
|
||||||
|
- nushell autocomplete
|
||||||
|
- manpage
|
||||||
|
|
||||||
If modrinth supports it:
|
Long-term/host-dependent:
|
||||||
- conflict resolution
|
- conflict resolution
|
||||||
- dependency resolution
|
- dependency resolution
|
||||||
|
- shaderpack and resource pack management
|
||||||
|
|
||||||
# File Architecture
|
# File Architecture
|
||||||
|
|
||||||
|
@ -76,12 +83,13 @@ $ hopper add sodium --mc-version 1.17
|
||||||
:: ...
|
:: ...
|
||||||
```
|
```
|
||||||
|
|
||||||
|
- configurable mod search results like [Starship](https://starship.rs)
|
||||||
- pad mod indices based on largest number
|
- pad mod indices based on largest number
|
||||||
- option in config to reverse sorting order
|
- option in config to reverse sorting order
|
||||||
- add parameter to restrict target Minecraft version
|
- add parameter to restrict target Minecraft version
|
||||||
- manually pick out Minecraft version
|
- manually pick out Minecraft version
|
||||||
- square creeper face progress indicator (from top-left clockwise spiral in)
|
- square colored creeper face progress indicator (from top-left clockwise spiral in)
|
||||||
|
|
||||||
## `hopper get`
|
## `hopper get`
|
||||||
|
|
||||||
Just like `hopper add` but simply downloads a mod jar.
|
Just like `hopper add` but simply downloads a mod jar to the current directory.
|
||||||
|
|
11
src/main.rs
11
src/main.rs
|
@ -3,13 +3,18 @@ use serde::{Deserialize, Serialize};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use structopt::StructOpt;
|
use structopt::StructOpt;
|
||||||
|
|
||||||
|
// TODO use ColoredHelp by default?
|
||||||
#[derive(StructOpt, Debug)]
|
#[derive(StructOpt, Debug)]
|
||||||
enum Command {
|
enum Command {
|
||||||
|
/// Adds a mod to the current instance
|
||||||
#[structopt(setting = structopt::clap::AppSettings::ColoredHelp)]
|
#[structopt(setting = structopt::clap::AppSettings::ColoredHelp)]
|
||||||
Install { package_name: String },
|
Add { package_name: String },
|
||||||
|
/// Removes a mod
|
||||||
#[structopt(setting = structopt::clap::AppSettings::ColoredHelp)]
|
#[structopt(setting = structopt::clap::AppSettings::ColoredHelp)]
|
||||||
Remove { package_name: String },
|
Remove { package_name: String },
|
||||||
#[structopt(setting = structopt::clap::AppSettings::ColoredHelp)]
|
#[structopt(setting = structopt::clap::AppSettings::ColoredHelp)]
|
||||||
|
Get { package_name: String },
|
||||||
|
#[structopt(setting = structopt::clap::AppSettings::ColoredHelp)]
|
||||||
Update,
|
Update,
|
||||||
#[structopt(setting = structopt::clap::AppSettings::ColoredHelp)]
|
#[structopt(setting = structopt::clap::AppSettings::ColoredHelp)]
|
||||||
Clean,
|
Clean,
|
||||||
|
@ -115,7 +120,7 @@ impl ModResult {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn cmd_install(config: &Config, package_name: String) -> anyhow::Result<()> {
|
async fn cmd_get(config: &Config, package_name: String) -> anyhow::Result<()> {
|
||||||
let client = reqwest::Client::new();
|
let client = reqwest::Client::new();
|
||||||
let url = format!("https://{}/api/v1/mod", config.upstream.server_address);
|
let url = format!("https://{}/api/v1/mod", config.upstream.server_address);
|
||||||
let params = [("query", package_name.as_str())];
|
let params = [("query", package_name.as_str())];
|
||||||
|
@ -138,7 +143,7 @@ async fn main() -> anyhow::Result<()> {
|
||||||
let args = Args::from_args();
|
let args = Args::from_args();
|
||||||
let config = args.load_config()?;
|
let config = args.load_config()?;
|
||||||
match args.command {
|
match args.command {
|
||||||
Command::Install { package_name } => cmd_install(&config, package_name).await,
|
Command::Get { package_name } => cmd_get(&config, package_name).await,
|
||||||
_ => unimplemented!("unimplemented subcommand"),
|
_ => unimplemented!("unimplemented subcommand"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue