refactor: use canonical module paths
This commit is contained in:
1 parent
c6205a337c
commit
feeb3e6d50
21 files changed
+28
-46
No files matched your search
+2
-2
@@ -8,7 +8,7 @@ use clap::ArgMatches;
|
||||
|
||||
use super::utils::{require_instance, required_arg};
|
||||
use crate::cli::output::print_table;
|
||||
use crate::instance::ContentEntry;
|
||||
use crate::instance::content::entry::ContentEntry;
|
||||
|
||||
type CliResult = Result<(), Box<dyn std::error::Error>>;
|
||||
type Scanner = fn(&Path, &str) -> Vec<ContentEntry>;
|
||||
@@ -106,7 +106,7 @@ fn toggle_entry(
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
crate::instance::toggle_entry(entry)?;
|
||||
crate::instance::content::entry::toggle_entry(entry)?;
|
||||
println!(
|
||||
"{}d '{}'.",
|
||||
if should_enable { "Enable" } else { "Disable" },
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use super::find_entry_by_stem;
|
||||
use crate::instance::ContentEntry;
|
||||
use crate::instance::content::entry::ContentEntry;
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn entry(file_stem: &str) -> ContentEntry {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// scanning and toggling instance content (mods, resource packs, shaders, worlds).
|
||||
// minecraft uses a ".disabled" suffix convention for disabled content, so this leans on that heavily.
|
||||
|
||||
mod entry;
|
||||
mod icons;
|
||||
pub mod entry;
|
||||
pub mod icons;
|
||||
pub mod manifest;
|
||||
pub mod mods;
|
||||
mod packs;
|
||||
@@ -12,8 +12,6 @@ pub mod resource_packs;
|
||||
pub mod shaders;
|
||||
pub mod worlds;
|
||||
|
||||
pub(crate) use entry::toggle_entry_path;
|
||||
pub use entry::{ContentEntry, toggle_entry};
|
||||
pub(crate) use icons::{
|
||||
IconCell, fallback_icon, fallback_icon_large, make_icon_pixels, make_icon_pixels_from_image,
|
||||
make_icon_quadrants_from_image,
|
||||
|
||||
@@ -9,8 +9,7 @@ use std::path::Path;
|
||||
|
||||
use serde::Deserialize;
|
||||
|
||||
pub use super::entry::{ContentEntry, toggle_entry};
|
||||
pub use super::icons::IconCell;
|
||||
use super::entry::ContentEntry;
|
||||
use super::icons::{fallback_icon, make_icon_pixels};
|
||||
|
||||
#[derive(Deserialize, Default)]
|
||||
|
||||
@@ -4,7 +4,8 @@ use std::path::Path;
|
||||
|
||||
use serde::Deserialize;
|
||||
|
||||
use super::{ContentEntry, fallback_icon, make_icon_pixels};
|
||||
use super::entry::ContentEntry;
|
||||
use super::{fallback_icon, make_icon_pixels};
|
||||
|
||||
#[derive(Deserialize, Default)]
|
||||
struct PackMcMeta {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use super::ContentEntry;
|
||||
use super::entry::ContentEntry;
|
||||
|
||||
pub fn scan_one_resource_pack(path: &Path, file_stem: &str, enabled: bool) -> ContentEntry {
|
||||
super::packs::scan_one_pack(path, file_stem, enabled)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use super::ContentEntry;
|
||||
use super::entry::ContentEntry;
|
||||
|
||||
pub fn scan_one_shader(path: &Path, file_stem: &str, enabled: bool) -> ContentEntry {
|
||||
super::packs::scan_one_pack(path, file_stem, enabled)
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use super::{ContentEntry, fallback_icon_large, make_icon_pixels};
|
||||
use super::entry::ContentEntry;
|
||||
use super::{fallback_icon_large, make_icon_pixels};
|
||||
|
||||
pub fn scan_one_world(path: &Path, file_stem: &str, enabled: bool) -> ContentEntry {
|
||||
let icon_bytes = std::fs::read(path.join("icon.png")).ok();
|
||||
|
||||
+2
-4
@@ -14,14 +14,12 @@ pub mod models;
|
||||
pub mod runtime;
|
||||
pub mod screenshots;
|
||||
|
||||
pub use logs::files as log_files;
|
||||
|
||||
pub use content::manifest::{
|
||||
ContentFileRecord, ContentKind, ContentManifest, FileFingerprint, ProviderProject, Resolution,
|
||||
};
|
||||
pub use content::{
|
||||
ContentEntry, scan_mods, scan_one_mod, scan_one_resource_pack, scan_one_shader, scan_one_world,
|
||||
scan_resource_packs, scan_shaders, scan_worlds, toggle_entry,
|
||||
scan_mods, scan_one_mod, scan_one_resource_pack, scan_one_shader, scan_one_world,
|
||||
scan_resource_packs, scan_shaders, scan_worlds,
|
||||
};
|
||||
pub use launch::LaunchError;
|
||||
pub use loader::{GameVersion, ModLoaderInstaller, VanillaInstaller, get_installer};
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use super::*;
|
||||
use crate::instance::content::entry::{ContentEntry, toggle_entry};
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn setup_mods_dir(tmp: &Path, instance: &str) -> PathBuf {
|
||||
|
||||
@@ -20,7 +20,4 @@ pub mod tui;
|
||||
pub(crate) mod tests;
|
||||
|
||||
pub use cli::init as cli_init;
|
||||
pub use instance::content::provider as content_provider;
|
||||
pub use instance::logs::live as instance_logs;
|
||||
pub use instance::runtime as running;
|
||||
pub use migrate::run_legacy_rename as migrate_legacy_rename;
|
||||
@@ -11,8 +11,6 @@ use crate::feedback::progress::set_action;
|
||||
use crate::instance::loader::GameVersion;
|
||||
use crate::net::{HttpClient, NetError, download_file};
|
||||
|
||||
pub use crate::instance::loader::forge::run_forge_installer;
|
||||
|
||||
const FORGE_PROMOTIONS_URL: &str =
|
||||
"https://files.minecraftforge.net/net/minecraftforge/forge/promotions_slim.json";
|
||||
const FORGE_MAVEN_BASE: &str = "https://maven.minecraftforge.net/net/minecraftforge/forge";
|
||||
|
||||
@@ -8,9 +8,6 @@ pub mod mojang;
|
||||
pub mod neoforge;
|
||||
pub mod quilt;
|
||||
|
||||
pub use crate::instance::java::detect_java_path;
|
||||
pub use crate::instance::loader::maven::maven_coord_to_path;
|
||||
|
||||
use reqwest::Client;
|
||||
use serde::Serialize;
|
||||
use serde::de::DeserializeOwned;
|
||||
|
||||
@@ -3,10 +3,6 @@
|
||||
use serde::Deserialize;
|
||||
use std::collections::HashMap;
|
||||
|
||||
pub use crate::instance::import::mrpack::{
|
||||
MrpackFile, MrpackIndex, game_version_from_dependencies, loader_from_dependencies, parse_mrpack,
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, serde::Serialize)]
|
||||
pub struct ProjectInfo {
|
||||
pub id: String,
|
||||
|
||||
@@ -11,8 +11,6 @@ use crate::feedback::progress::set_action;
|
||||
use crate::instance::loader::GameVersion;
|
||||
use crate::net::{HttpClient, NetError, download_file};
|
||||
|
||||
pub use crate::instance::loader::neoforge::run_neoforge_installer;
|
||||
|
||||
const NEOFORGE_MAVEN_BASE: &str = "https://maven.neoforged.net/releases/net/neoforged/neoforge";
|
||||
const NEOFORGE_API_BASE: &str =
|
||||
"https://maven.neoforged.net/api/maven/versions/releases/net/neoforged/neoforge";
|
||||
|
||||
+1
-3
@@ -7,9 +7,7 @@ pub mod logging;
|
||||
mod render;
|
||||
pub mod widgets;
|
||||
|
||||
pub use crate::feedback::errors as error_buffer;
|
||||
pub use crate::feedback::progress;
|
||||
pub use crate::feedback::request_redraw;
|
||||
use crate::feedback::request_redraw;
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) mod tests;
|
||||
|
||||
@@ -4,7 +4,7 @@ use std::{
|
||||
sync::{Arc, Mutex},
|
||||
};
|
||||
|
||||
use crate::instance::ContentEntry;
|
||||
use crate::instance::content::entry::ContentEntry;
|
||||
use ratatui::{
|
||||
buffer::Buffer,
|
||||
layout::Rect,
|
||||
|
||||
@@ -3,7 +3,8 @@ use std::sync::{Arc, Mutex};
|
||||
|
||||
use crossterm::event::{KeyCode, KeyEvent};
|
||||
|
||||
use crate::instance::{ContentEntry, ContentKind, InstanceConfig, ModLoader};
|
||||
use crate::instance::content::entry::ContentEntry;
|
||||
use crate::instance::{ContentKind, InstanceConfig, ModLoader};
|
||||
use crate::net::modrinth::{DiscoveryProject, VersionInfo};
|
||||
|
||||
use super::list::{ContentListState, ContentStream};
|
||||
|
||||
@@ -20,7 +20,8 @@ use ratatui_image::{CropOptions, Resize, StatefulImage, protocol::StatefulProtoc
|
||||
use tui_widget_list::{ListBuilder, ListState as TuiListState, ListView};
|
||||
|
||||
use crate::config::theme::THEME;
|
||||
use crate::instance::content::{ContentEntry, IconCell};
|
||||
use crate::instance::content::entry::ContentEntry;
|
||||
use crate::instance::content::icons::IconCell;
|
||||
|
||||
type ScanOneFn = fn(&Path, &str, bool) -> ContentEntry;
|
||||
static PROVIDER_ICON_SLOTS: LazyLock<Arc<tokio::sync::Semaphore>> =
|
||||
@@ -1161,7 +1162,7 @@ impl ContentListState {
|
||||
let Some(entry) = self.entries.get(index) else {
|
||||
return;
|
||||
};
|
||||
match crate::instance::content::toggle_entry_path(entry) {
|
||||
match crate::instance::content::entry::toggle_entry_path(entry) {
|
||||
Ok(Some(new_path)) => {
|
||||
let entry = &mut self.entries[index];
|
||||
entry.enabled = !entry.enabled;
|
||||
@@ -1954,10 +1955,7 @@ fn ellipsize(text: &str, max_width: usize) -> String {
|
||||
visible
|
||||
}
|
||||
|
||||
fn protocol_icon_columns(
|
||||
entry: &crate::instance::ContentEntry,
|
||||
picker: &ratatui_image::picker::Picker,
|
||||
) -> u16 {
|
||||
fn protocol_icon_columns(entry: &ContentEntry, picker: &ratatui_image::picker::Picker) -> u16 {
|
||||
let rows = entry.icon_lines.as_ref().map_or(3, Vec::len) as u16;
|
||||
let font_size = picker.font_size();
|
||||
square_icon_columns(rows, (font_size.width, font_size.height))
|
||||
@@ -2081,7 +2079,7 @@ fn diff_event_paths(
|
||||
fn watcher_diff(
|
||||
toggled: Vec<(String, bool, std::path::PathBuf)>,
|
||||
removed: Vec<String>,
|
||||
added: Vec<crate::instance::ContentEntry>,
|
||||
added: Vec<ContentEntry>,
|
||||
) -> Option<WatcherDiff> {
|
||||
if toggled.is_empty() && removed.is_empty() && added.is_empty() {
|
||||
None
|
||||
|
||||
@@ -17,7 +17,8 @@ use crate::tui::widgets::content::{ContentMode, DiscoveryState};
|
||||
|
||||
use crate::tui::widgets::styled_title;
|
||||
|
||||
type ContentScanner = fn(&std::path::Path, &str, bool) -> crate::instance::ContentEntry;
|
||||
type ContentScanner =
|
||||
fn(&std::path::Path, &str, bool) -> crate::instance::content::entry::ContentEntry;
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
struct DownloadableTab {
|
||||
|
||||
Reference in new issue
Block a user