Add hopfile.rs, Hopfile-example.toml, and update cmd
This commit is contained in:
parent
b4ab1bf1d4
commit
2d7e71b14a
|
@ -1 +1,2 @@
|
|||
/instance-example
|
||||
/target
|
||||
|
|
|
@ -357,6 +357,7 @@ dependencies = [
|
|||
"serde_json",
|
||||
"structopt",
|
||||
"tokio",
|
||||
"toml",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
|
@ -18,3 +18,4 @@ serde = { version = "1", features = ["derive"] }
|
|||
serde_json = "1"
|
||||
structopt = "0.3"
|
||||
tokio = { version = "1", features = ["full"] }
|
||||
toml = "0.5"
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
version = "1.18"
|
||||
|
||||
[mods.sodium]
|
|
@ -24,7 +24,7 @@ pub enum Command {
|
|||
#[structopt(setting = structopt::clap::AppSettings::ColoredHelp)]
|
||||
Get(SearchArgs),
|
||||
#[structopt(setting = structopt::clap::AppSettings::ColoredHelp)]
|
||||
Update,
|
||||
Update { instance_dir: Option<PathBuf> },
|
||||
#[structopt(setting = structopt::clap::AppSettings::ColoredHelp)]
|
||||
Clean,
|
||||
}
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
use serde::Deserialize;
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct ModEntry {}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct Hopfile {
|
||||
pub version: String,
|
||||
pub mods: HashMap<String, ModEntry>,
|
||||
}
|
14
src/main.rs
14
src/main.rs
|
@ -2,13 +2,16 @@ use futures_util::StreamExt;
|
|||
use log::*;
|
||||
use std::cmp::min;
|
||||
use std::io::Write;
|
||||
use std::path::PathBuf;
|
||||
use structopt::StructOpt;
|
||||
|
||||
mod api;
|
||||
mod config;
|
||||
mod hopfile;
|
||||
|
||||
use api::*;
|
||||
use config::*;
|
||||
use hopfile::*;
|
||||
|
||||
async fn search_mods(ctx: &AppContext, search_args: &SearchArgs) -> anyhow::Result<SearchResponse> {
|
||||
let client = reqwest::Client::new();
|
||||
|
@ -182,6 +185,16 @@ async fn cmd_get(ctx: &AppContext, search_args: SearchArgs) -> anyhow::Result<()
|
|||
Ok(())
|
||||
}
|
||||
|
||||
async fn cmd_update(ctx: &AppContext, instance_dir: Option<PathBuf>) -> anyhow::Result<()> {
|
||||
let instance_dir = instance_dir.unwrap_or(std::env::current_dir()?);
|
||||
let hopfile = std::fs::read_to_string(instance_dir.join("Hopfile.toml"))?;
|
||||
let hopfile: Hopfile = toml::from_str(&hopfile)?;
|
||||
|
||||
println!("hopfile: {:#?}", hopfile);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> anyhow::Result<()> {
|
||||
env_logger::init();
|
||||
|
@ -190,6 +203,7 @@ async fn main() -> anyhow::Result<()> {
|
|||
let ctx = AppContext { args, config };
|
||||
match ctx.args.to_owned().command {
|
||||
Command::Get(search_args) => cmd_get(&ctx, search_args).await,
|
||||
Command::Update { instance_dir } => cmd_update(&ctx, instance_dir).await,
|
||||
_ => unimplemented!("unimplemented subcommand"),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue