-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,3 +71,4 @@ ratatui = "0.27.0" | |
tokio-tungstenite = "0.23.1" | ||
log = "0.4.22" | ||
env_logger = "0.11.3" | ||
toml_edit = "0.22" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ pub mod zip; | |
pub mod toml; | ||
pub mod fs; | ||
pub mod logger; | ||
pub mod update_writer; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use std::path::{Path, PathBuf}; | ||
|
||
use anyhow::{anyhow, Result}; | ||
use toml_edit::DocumentMut; | ||
use zip::ZipArchive; | ||
|
||
use crate::api::{app::App, models::{mrpack::MRPackIndex, packwiz::{PackwizPack, PackwizPackIndex}, ModpackSource, ModpackType, Source, SourceType}}; | ||
Check warning on line 7 in src/api/utils/update_writer.rs GitHub Actions / clippyunused imports: `ModpackSource`, `ModpackType`, `SourceType`, and `app::App`
|
||
|
||
use super::toml::read_toml; | ||
Check warning on line 9 in src/api/utils/update_writer.rs GitHub Actions / clippyunused import: `super::toml::read_toml`
|
||
|
||
/// An `Accessor` allows for filesystem, remote or zip file access. | ||
pub enum UpdateWriter { | ||
File(PathBuf, DocumentMut), | ||
MRPack(PathBuf, ZipArchive<std::fs::File>, MRPackIndex), | ||
Packwiz(PathBuf, PackwizPack, PackwizPackIndex), | ||
} | ||
|
||
impl UpdateWriter { | ||
pub fn from(source: &Source, relative_to: &Path) -> Result<Self> { | ||
Check warning on line 19 in src/api/utils/update_writer.rs GitHub Actions / clippyassociated function `from` is never used
Check warning on line 19 in src/api/utils/update_writer.rs GitHub Actions / clippyunused variable: `relative_to`
Check warning on line 19 in src/api/utils/update_writer.rs GitHub Actions / clippyunused variable: `source`
|
||
todo!(); | ||
|
||
/* match &source.source_type { | ||
SourceType::File { path } => Ok(Self::File(path, read_toml(relative_to.join(path).to_path_buf())?)), | ||
SourceType::Folder { path } => unimplemented!(), | ||
SourceType::Modpack { | ||
modpack_source: ModpackSource::Local { path, can_update: true }, | ||
modpack_type | ||
} => match modpack_type { | ||
ModpackType::MRPack => Ok(Self::MRPack( | ||
relative_to.join(path).to_path_buf(), | ||
ZipArchive::new(std::fs::File::open(relative_to.join(path))?)?, | ||
todo!() | ||
)), | ||
ModpackType::Packwiz => Ok(Self::Packwiz( | ||
relative_to.join(path), | ||
todo!(), | ||
todo!(), | ||
)), | ||
ModpackType::Unsup => unimplemented!(), | ||
}, | ||
_ => Err(anyhow!("Can't make an UpdateWriter")), | ||
} */ | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
use std::sync::Arc; | ||
|
||
use anyhow::Result; | ||
|
||
use crate::api::app::App; | ||
|
||
pub mod mrpack; | ||
pub mod packwiz; | ||
|
||
#[derive(clap::Subcommand)] | ||
pub enum Commands { | ||
MRPack(mrpack::Args), | ||
Packwiz(packwiz::Args), | ||
} | ||
|
||
pub async fn run(app: Arc<App>, args: Commands) -> Result<()> { | ||
match args { | ||
Commands::MRPack(args) => mrpack::run(app, args).await, | ||
Commands::Packwiz(args) => packwiz::run(app, args).await, | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
use std::sync::Arc; | ||
|
||
use anyhow::Result; | ||
|
||
use crate::api::app::App; | ||
|
||
#[derive(clap::Args)] | ||
pub struct Args { | ||
filename: Option<String>, | ||
} | ||
|
||
pub async fn run(app: Arc<App>, args: Args) -> Result<()> { | ||
Check warning on line 12 in src/commands/export/mrpack.rs GitHub Actions / clippyunused variable: `args`
Check warning on line 12 in src/commands/export/mrpack.rs GitHub Actions / clippyunused variable: `app`
|
||
|
||
|
||
Ok(()) | ||
} | ||
Check warning on line 16 in src/commands/export/mrpack.rs GitHub Actions / clippyunused `async` for function with no await statements
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
use std::sync::Arc; | ||
|
||
use anyhow::Result; | ||
|
||
use crate::api::app::App; | ||
|
||
#[derive(clap::Args)] | ||
pub struct Args { | ||
|
||
} | ||
|
||
pub async fn run(app: Arc<App>, args: Args) -> Result<()> { | ||
Check warning on line 12 in src/commands/export/packwiz.rs GitHub Actions / clippyunused variable: `args`
Check warning on line 12 in src/commands/export/packwiz.rs GitHub Actions / clippyunused variable: `app`
|
||
|
||
|
||
Ok(()) | ||
} | ||
Check warning on line 16 in src/commands/export/packwiz.rs GitHub Actions / clippyunused `async` for function with no await statements
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ pub mod migrate; | |
pub mod websocket; | ||
pub mod run; | ||
pub mod update; | ||
pub mod export; |