Rafactored most of the important modules
This commit is contained in:
parent
725cd9cfc4
commit
9d302d4d45
45
Todo.md
45
Todo.md
|
|
@ -1,29 +1,50 @@
|
|||
# Current Tools
|
||||
## TableGen
|
||||
|
||||
# Workspaces
|
||||
[~] Table
|
||||
[~] Cleanup
|
||||
[~] Config
|
||||
[~] Cleanup
|
||||
[x] Doc
|
||||
[~] Stats
|
||||
[~] Cleanup
|
||||
[~] Make
|
||||
[~] Cleanup
|
||||
[ ] Graphs
|
||||
[~] Cleanup
|
||||
[ ] Cli Parser
|
||||
[ ] Refactor
|
||||
[ ] Cleanup
|
||||
[ ] Doc
|
||||
|
||||
# Todo
|
||||
* Auto path (by default)
|
||||
* Document
|
||||
[ ] Auto path (by default)
|
||||
[ ] Document
|
||||
[ ] Remove most of the unneeded pub
|
||||
[ ] Update the dependencies
|
||||
[ ] Remove unneded dependencies
|
||||
[ ] Switch from anyhow to thiserror
|
||||
|
||||
## Tablegen
|
||||
* Dissociate path from feature
|
||||
* Force replace/ask
|
||||
* Have interactive mode ?
|
||||
* Dissociate Model from generation
|
||||
[ ] Dissociate path from feature
|
||||
[ ] Force replace/ask
|
||||
[ ] Have interactive mode ?
|
||||
[ ] Dissociate Model from generation
|
||||
|
||||
## StatGen
|
||||
* Get rid of cycle and have a struct that gives stats according to % and keeps tracks of %
|
||||
* Test VecDeque
|
||||
* Add testing
|
||||
* Add the swap algo (swap a bad fit creature with another)
|
||||
* Save/load states
|
||||
[ ] Get rid of cycle and have a struct that gives stats according to % and keeps tracks of %
|
||||
[ ] Test VecDeque
|
||||
[ ] Add testing
|
||||
[ ] Add the swap algo (swap a bad fit creature with another)
|
||||
[ ] Save/load states
|
||||
|
||||
## Test Units
|
||||
|
||||
|
||||
|
||||
# Futures tools
|
||||
* Lexer/Checker
|
||||
[ ] Lexer/Checker
|
||||
|
||||
## Lexer
|
||||
` Command: grammar --check `
|
||||
|
|
|
|||
|
|
@ -5,24 +5,5 @@ edition = "2024"
|
|||
|
||||
[dependencies]
|
||||
config = {path = "../config"}
|
||||
anyhow = "1.0.95"
|
||||
clap = { version = "4.5.28", features = ["derive"] }
|
||||
serde = { version = "1.0.217", features = ["derive", "alloc"] }
|
||||
|
||||
# charts-rs = { version = "0.3.11" }
|
||||
# console = "0.15.8"
|
||||
# csv = "1.3.0"
|
||||
# debug_print = "1.0.0"
|
||||
# dynfmt = { version = "0.1.5", features = ["curly"] }
|
||||
# glob = "0.3.1"
|
||||
# indexmap = "2.2.6"
|
||||
# indicatif = "0.17.8"
|
||||
# logos = "0.14.0"
|
||||
# phf = { version = "0.11.2", features = ["macros"] }
|
||||
# regex = "1.10.5"
|
||||
# regex_static = "0.1.1"
|
||||
# ron = "0.8.1"
|
||||
# serde = { version = "1.0.203", features = ["derive"] }
|
||||
# serde_json = "1.0.117"
|
||||
# tokio = { version = "1.38.0", features = ["full"] }
|
||||
# toml = "0.8.14"
|
||||
|
|
|
|||
|
|
@ -1,10 +1,13 @@
|
|||
use clap::{Args, Parser, Subcommand};
|
||||
use config::HELP_BLOCK_SELECTION;
|
||||
use config::HELP_BUILD_TARGET_LIST;
|
||||
use config::HELP_VERBOSITY_LEVEL;
|
||||
use config::MakeTargets;
|
||||
use config::VerboseLevel;
|
||||
use config::{Craft, GraphConfig, StatConfig, TableArgs};
|
||||
use config::{
|
||||
graph::GraphConfig,
|
||||
make::{
|
||||
HELP_BLOCK_SELECTION, HELP_BUILD_TARGET_LIST, HELP_VERBOSITY_LEVEL, MakeTargets,
|
||||
VerboseLevel,
|
||||
},
|
||||
statsolver::StatConfig,
|
||||
tablegen::{Craft, TableArgs},
|
||||
};
|
||||
use serde::Deserialize;
|
||||
|
||||
// use graphs::{GraphConfig, make_graphs};
|
||||
|
|
|
|||
|
|
@ -4,22 +4,6 @@ version = "0.1.0"
|
|||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0.86"
|
||||
charts-rs = { version = "0.3.11" }
|
||||
clap = { version = "4.5.7", features = ["derive"] }
|
||||
console = "0.15.8"
|
||||
csv = "1.3.0"
|
||||
debug_print = "1.0.0"
|
||||
dynfmt = { version = "0.1.5", features = ["curly"] }
|
||||
glob = "0.3.1"
|
||||
indexmap = "2.2.6"
|
||||
indicatif = "0.17.8"
|
||||
logos = "0.14.0"
|
||||
phf = { version = "0.11.2", features = ["macros"] }
|
||||
regex = "1.10.5"
|
||||
regex_static = "0.1.1"
|
||||
ron = "0.8.1"
|
||||
serde = { version = "1.0.203", features = ["derive"] }
|
||||
serde_json = "1.0.117"
|
||||
tokio = { version = "1.38.0", features = ["full"] }
|
||||
toml = "0.8.14"
|
||||
clap = { version = "4.5.28", features = ["derive"] }
|
||||
phf = { version = "0.11.3", features = ["macros"] }
|
||||
serde = { version = "1.0.217", features = ["derive"] }
|
||||
|
|
|
|||
|
|
@ -0,0 +1,81 @@
|
|||
// Workspace: config
|
||||
// File: config/src/graph.rs
|
||||
// Graphconfig
|
||||
use clap::Args;
|
||||
use phf::phf_map;
|
||||
use std::sync::LazyLock;
|
||||
|
||||
#[derive(Args, Debug, Clone)]
|
||||
/// The configuration struct for the PdfMaker
|
||||
pub struct GraphConfig {
|
||||
/// Special target
|
||||
#[arg(help = format!("The target to execute [{}]", *HELP_STR_TO_GRAPH))]
|
||||
pub target: GraphTargetType,
|
||||
|
||||
/// Alternative origin
|
||||
#[arg(short, long, default_value = "Images/Radar/radar.csv")]
|
||||
pub origin: String,
|
||||
|
||||
/// Alternative destination
|
||||
#[arg(short, long, default_value = "Images/Radar")]
|
||||
pub destination: String,
|
||||
|
||||
/// Alternative config to load (generate a new one with init)
|
||||
#[arg(short, long)]
|
||||
pub config: Option<String>,
|
||||
|
||||
/// Clean all the artefacts (including generated images)
|
||||
#[arg(short, long)]
|
||||
pub all: bool,
|
||||
}
|
||||
|
||||
/// Link from user str input to the action to perform
|
||||
static STR_TO_GRAPH_TARGET_TYPE: phf::Map<&'static str, GraphTargetType> = phf_map! {
|
||||
"generate" => GraphTargetType::Generate,
|
||||
"gen" => GraphTargetType::Generate,
|
||||
"remove" => GraphTargetType::Remove,
|
||||
"clean" => GraphTargetType::Remove,
|
||||
"init" => GraphTargetType::Init,
|
||||
};
|
||||
|
||||
/// Help listing all the actions availables
|
||||
pub static HELP_STR_TO_GRAPH: LazyLock<String> = LazyLock::new(|| {
|
||||
let targets = STR_TO_GRAPH_TARGET_TYPE
|
||||
.keys()
|
||||
.map(|v| v.to_string())
|
||||
.collect::<Vec<String>>();
|
||||
targets.join(", ").to_string()
|
||||
});
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
/// All target type
|
||||
pub enum GraphTargetType {
|
||||
// TODO: Check this pub BS
|
||||
/// Make all graphs
|
||||
Generate,
|
||||
/// Clean all graphs
|
||||
Remove,
|
||||
/// Initialize the connfig
|
||||
Init,
|
||||
}
|
||||
impl From<&str> for GraphTargetType {
|
||||
fn from(value: &str) -> Self {
|
||||
if let Some(target) = STR_TO_GRAPH_TARGET_TYPE.get(&value.to_lowercase()).cloned() {
|
||||
target
|
||||
} else {
|
||||
panic!(
|
||||
"Invalid target {}. The target available are : [{}]",
|
||||
value, *HELP_STR_TO_GRAPH
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// #[cfg(test)]
|
||||
// mod tests {
|
||||
// use super::*;
|
||||
|
||||
// #[test]
|
||||
// fn it_works() {}
|
||||
// }
|
||||
//
|
||||
|
|
@ -1,337 +1,11 @@
|
|||
// Workspace: config
|
||||
// File: config/src/lib.rs
|
||||
//! Holds config and traits
|
||||
//!
|
||||
//! Also write configs to disk
|
||||
|
||||
//! Holds all the data structures away from the main routine
|
||||
use clap::Args;
|
||||
use phf::phf_map;
|
||||
use serde::Deserialize;
|
||||
use std::{collections::HashMap, fmt::Debug, sync::LazyLock};
|
||||
|
||||
// Table generation structs
|
||||
|
||||
/// An enumeration representing different target types.
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum TableGenerationTarget {
|
||||
/// Processes all classes
|
||||
Classes,
|
||||
/// Processes all the craft tables
|
||||
Craft,
|
||||
/// Processes only the given files
|
||||
Files,
|
||||
/// Processes all the known targets
|
||||
All,
|
||||
}
|
||||
|
||||
impl From<&str> for TableGenerationTarget {
|
||||
fn from(value: &str) -> Self {
|
||||
if let Some(target) = STR_TO_TARGET.get(value).cloned() {
|
||||
target
|
||||
} else {
|
||||
panic!(
|
||||
"Only the following target can be used: {}",
|
||||
*HELP_STR_TO_TARGET_TABLES
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A mapping of string representations to target types.
|
||||
static STR_TO_TARGET: phf::Map<&'static str, TableGenerationTarget> = phf_map! {
|
||||
"classes" => TableGenerationTarget::Classes,
|
||||
"craft" => TableGenerationTarget::Craft,
|
||||
"files" => TableGenerationTarget::Files,
|
||||
"all" => TableGenerationTarget::All,
|
||||
};
|
||||
|
||||
/// A help of all the table targets to be built
|
||||
pub static HELP_STR_TO_TARGET_TABLES: LazyLock<String> = LazyLock::new(|| {
|
||||
let mut targets = STR_TO_TARGET
|
||||
.keys()
|
||||
.map(|v| v.to_string())
|
||||
.collect::<Vec<String>>();
|
||||
targets.sort();
|
||||
targets.join(", ").to_string()
|
||||
});
|
||||
/// Configuration options for processing TSV files and generating LaTeX tables.
|
||||
#[derive(Debug, Args)]
|
||||
pub struct TableArgs {
|
||||
/// Wether to export all files (if used), or output everything to stdout
|
||||
#[arg(short)]
|
||||
pub export: bool,
|
||||
|
||||
/// The kind of tables to operate on: classes, craft or files followed by a list of files
|
||||
// #[arg(help = format!("The kind of tables to operate on : {}", "TODO: FIX"))]
|
||||
#[arg(help = format!("The kind of tables to operate on : {}", *HELP_STR_TO_TARGET_TABLES))]
|
||||
pub kind: TableGenerationTarget,
|
||||
/// A vector of strings representing the names of TSV files to process.
|
||||
pub filenames: Vec<String>,
|
||||
}
|
||||
|
||||
// This config is can contain unconstructed code for compatibility purposes
|
||||
#[allow(dead_code)]
|
||||
#[derive(Deserialize)]
|
||||
/// The Craft configs
|
||||
pub struct Craft {
|
||||
/// The food header string formatter
|
||||
pub header_food: String,
|
||||
/// The alchemy header string formatter
|
||||
pub header_alchemy: String,
|
||||
/// The forge header string formatter
|
||||
pub header_forge: String,
|
||||
/// The mtrap header string formatter
|
||||
pub header_mtrap: String,
|
||||
/// The weapons header string formatter
|
||||
pub header_weapons: String,
|
||||
/// The armors header string formatter
|
||||
pub header_armors: String,
|
||||
/// The gadgets header string formatter
|
||||
pub header_gadgets: String,
|
||||
/// The potions header string formatter
|
||||
pub header_potions: String,
|
||||
/// The traps header string formatter
|
||||
pub header_traps: String,
|
||||
/// The table end string formatter
|
||||
pub end: String,
|
||||
/// The long table end string formatter
|
||||
pub end_long: String,
|
||||
/// The long sideways table end string formatter
|
||||
pub end_long_side: String,
|
||||
/// The no_headers table end string formatter
|
||||
pub end_empty: String,
|
||||
}
|
||||
|
||||
// Statsolver Structs
|
||||
|
||||
#[derive(Args, Debug, Clone)]
|
||||
/// The configuration struct for the StatSolver
|
||||
pub struct StatConfig {
|
||||
// #[arg(default_value_t: "data/Book1.csv")]
|
||||
/// The path where the data to analyse is
|
||||
pub config_path: String,
|
||||
/// The verbosity level
|
||||
#[arg(short, long, default_value_t = false)]
|
||||
pub verbosity: bool,
|
||||
}
|
||||
|
||||
// Graphconfig
|
||||
#[derive(Args, Debug, Clone)]
|
||||
/// The configuration struct for the PdfMaker
|
||||
pub struct GraphConfig {
|
||||
/// Special target
|
||||
#[arg(help = format!("The target to execute [{}]", *HELP_STR_TO_GRAPH))]
|
||||
pub target: GraphTargetType,
|
||||
|
||||
/// Alternative origin
|
||||
#[arg(short, long, default_value = "Images/Radar/radar.csv")]
|
||||
pub origin: String,
|
||||
|
||||
/// Alternative destination
|
||||
#[arg(short, long, default_value = "Images/Radar")]
|
||||
pub destination: String,
|
||||
|
||||
/// Alternative config to load (generate a new one with init)
|
||||
#[arg(short, long)]
|
||||
pub config: Option<String>,
|
||||
|
||||
/// Clean all the artefacts (including generated images)
|
||||
#[arg(short, long)]
|
||||
pub all: bool,
|
||||
}
|
||||
|
||||
/// Link from user str input to the action to perform
|
||||
static STR_TO_GRAPH_TARGET_TYPE: phf::Map<&'static str, GraphTargetType> = phf_map! {
|
||||
"generate" => GraphTargetType::Generate,
|
||||
"gen" => GraphTargetType::Generate,
|
||||
"remove" => GraphTargetType::Remove,
|
||||
"clean" => GraphTargetType::Remove,
|
||||
"init" => GraphTargetType::Init,
|
||||
};
|
||||
|
||||
/// Help listing all the actions availables
|
||||
pub static HELP_STR_TO_GRAPH: LazyLock<String> = LazyLock::new(|| {
|
||||
let targets = STR_TO_GRAPH_TARGET_TYPE
|
||||
.keys()
|
||||
.map(|v| v.to_string())
|
||||
.collect::<Vec<String>>();
|
||||
targets.join(", ").to_string()
|
||||
});
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
/// All target type
|
||||
pub enum GraphTargetType {
|
||||
// TODO: Check this pub BS
|
||||
/// Make all graphs
|
||||
Generate,
|
||||
/// Clean all graphs
|
||||
Remove,
|
||||
/// Initialize the connfig
|
||||
Init,
|
||||
}
|
||||
impl From<&str> for GraphTargetType {
|
||||
fn from(value: &str) -> Self {
|
||||
if let Some(target) = STR_TO_GRAPH_TARGET_TYPE.get(&value.to_lowercase()).cloned() {
|
||||
target
|
||||
} else {
|
||||
panic!(
|
||||
"Invalid target {}. The target available are : [{}]",
|
||||
value, *HELP_STR_TO_GRAPH
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// #[cfg(test)]
|
||||
// mod tests {
|
||||
// use super::*;
|
||||
|
||||
// #[test]
|
||||
// fn it_works() {}
|
||||
// }
|
||||
//
|
||||
|
||||
// Make
|
||||
|
||||
/// Convert str to verbosity level
|
||||
static STR_TO_VERBOSITY: phf::Map<&'static str, VerboseLevel> = phf_map! {
|
||||
"misc" =>VerboseLevel::Misc,
|
||||
"box" => VerboseLevel::Box,
|
||||
"context" => VerboseLevel::Context,
|
||||
"info" => VerboseLevel::Info,
|
||||
"warning" => VerboseLevel::Warning,
|
||||
"error" => VerboseLevel::Error,
|
||||
"critical" => VerboseLevel::Critical,
|
||||
};
|
||||
|
||||
/// Convert str to build target
|
||||
static STR_TO_BUILD_TARGET: phf::Map<&'static str, MakeTargets> = phf_map! {
|
||||
"all" => MakeTargets::All,
|
||||
"list" => MakeTargets::List,
|
||||
"glossaries" => MakeTargets::Glossaries,
|
||||
"clean" => MakeTargets::Clean,
|
||||
};
|
||||
|
||||
/// List all blocktype
|
||||
pub static HELP_BLOCK_SELECTION: LazyLock<String> = LazyLock::new(|| {
|
||||
let mut targets = BLOCK_PROGRESSION
|
||||
.keys()
|
||||
.map(|v| v.to_owned())
|
||||
.collect::<Vec<String>>();
|
||||
targets.sort();
|
||||
targets.join(", ").to_string()
|
||||
});
|
||||
|
||||
/// List all targets
|
||||
pub static HELP_VERBOSITY_LEVEL: LazyLock<String> = LazyLock::new(|| {
|
||||
let mut targets = STR_TO_VERBOSITY
|
||||
.values()
|
||||
.map(|v| format!("{:?}", v).to_lowercase())
|
||||
.collect::<Vec<String>>();
|
||||
targets.sort();
|
||||
targets.join(", ").to_string()
|
||||
});
|
||||
|
||||
/// List all targets
|
||||
pub static HELP_BUILD_TARGET_LIST: LazyLock<String> = LazyLock::new(|| {
|
||||
let targets = STR_TO_BUILD_TARGET
|
||||
.values()
|
||||
.map(|v| format!("{:?}", v).to_lowercase())
|
||||
.collect::<Vec<String>>();
|
||||
targets.join(", ").to_string()
|
||||
});
|
||||
|
||||
/// The verbosity level
|
||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub enum VerboseLevel {
|
||||
/// Shouldn't be printed no matter what
|
||||
None,
|
||||
/// Garbage
|
||||
Misc,
|
||||
/// Boxness, barely above Misc
|
||||
Box,
|
||||
/// Context info (Debug info)
|
||||
Context,
|
||||
/// Usefull info
|
||||
Info,
|
||||
/// Important warnings
|
||||
Warning,
|
||||
/// Errors encountered requiring user input
|
||||
Error,
|
||||
/// Uncatachable errors
|
||||
Critical,
|
||||
/// Literrally uncatchable things
|
||||
Uncatchable,
|
||||
}
|
||||
impl From<&str> for VerboseLevel {
|
||||
fn from(value: &str) -> Self {
|
||||
if let Some(target) = STR_TO_VERBOSITY.get(&value.to_lowercase()).cloned() {
|
||||
target
|
||||
} else {
|
||||
panic!(
|
||||
"Invalid debug level {}. The debug level available are (from highest verbosity to lowest): [{:?}]",
|
||||
value, HELP_VERBOSITY_LEVEL
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// All progress bar styles
|
||||
pub static BLOCK_PROGRESSION: LazyLock<HashMap<String, String>> = LazyLock::new(|| {
|
||||
let mut m = HashMap::new();
|
||||
m.insert("class".to_string(), "#>-".to_string());
|
||||
m.insert("cargo".to_string(), "#> ".to_string());
|
||||
m.insert("rough".to_string(), "█ ".to_string());
|
||||
m.insert("fine".to_string(), "█▉▊▋▌▍▎▏ ".to_string());
|
||||
m.insert("vert".to_string(), "█▇▆▅▄▃▂▁ ".to_string());
|
||||
m.insert("fade".to_string(), "█▓▒░ ".to_string());
|
||||
m.insert("block".to_string(), "█▛▌▖ ".to_string());
|
||||
m.insert("curse".to_string(), "▓▙▚▐▔ ▛▘▖▄▟▞▂█".to_string());
|
||||
m.insert("load".to_string(), " ⱠØ₳Đł₦₲ ".to_string());
|
||||
m.insert("cool".to_string(), "▰▱".to_string());
|
||||
m.insert("neo".to_string(), "▰═".to_string());
|
||||
m
|
||||
});
|
||||
// Spinners
|
||||
// ▁ ▂ ▃ ▄ ▅ ▆ ▇ █ ▇ ▆ ▅ ▄ ▃ ▁
|
||||
// ▉▊▋▌▍▎▏▎▍▌▋▊▉
|
||||
// ▖ ▘ ▝ ▗
|
||||
// ┤ ┘ ┴ └ ├ ┌ ┬ ┐
|
||||
// ◢ ◣ ◤ ◥
|
||||
// ◡◡ ⊙⊙ ◠◠
|
||||
// ⣾⣽⣻⢿⡿⣟⣯⣷ ⠁⠂⠄⡀⢀⠠⠐⠈
|
||||
// .tick_strings(&[
|
||||
// "▹▹▹▹▹",
|
||||
// "▸▹▹▹▹",
|
||||
// "▹▸▹▹▹",
|
||||
// "▹▹▸▹▹",
|
||||
// "▹▹▹▸▹",
|
||||
// "▹▹▹▹▸",
|
||||
// "▪▪▪▪▪",
|
||||
// ]),
|
||||
//
|
||||
|
||||
/// List of all alternative targets
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum MakeTargets {
|
||||
/// Make all targets
|
||||
All,
|
||||
/// Make a list of all optionals
|
||||
List,
|
||||
/// Make glossaries
|
||||
Glossaries,
|
||||
/// Make the working directory clean
|
||||
Clean,
|
||||
}
|
||||
|
||||
impl From<&str> for MakeTargets {
|
||||
fn from(value: &str) -> Self {
|
||||
if let Some(target) = STR_TO_BUILD_TARGET.get(&value.to_lowercase()).cloned() {
|
||||
target
|
||||
} else {
|
||||
panic!(
|
||||
"Invalid build target {}. The build target available are [{:?}]",
|
||||
value, HELP_BUILD_TARGET_LIST
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
// Internal Modules
|
||||
pub mod graph;
|
||||
pub mod make;
|
||||
pub mod statsolver;
|
||||
pub mod tablegen;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,150 @@
|
|||
// Workspace: config
|
||||
// File: config/src/make.rs
|
||||
// Makepdf generation structs
|
||||
|
||||
use phf::phf_map;
|
||||
use std::{collections::HashMap, fmt::Debug, sync::LazyLock};
|
||||
|
||||
/// Convert str to verbosity level
|
||||
static STR_TO_VERBOSITY: phf::Map<&'static str, VerboseLevel> = phf_map! {
|
||||
"misc" =>VerboseLevel::Misc,
|
||||
"box" => VerboseLevel::Box,
|
||||
"context" => VerboseLevel::Context,
|
||||
"info" => VerboseLevel::Info,
|
||||
"warning" => VerboseLevel::Warning,
|
||||
"error" => VerboseLevel::Error,
|
||||
"critical" => VerboseLevel::Critical,
|
||||
};
|
||||
|
||||
/// Convert str to build target
|
||||
static STR_TO_BUILD_TARGET: phf::Map<&'static str, MakeTargets> = phf_map! {
|
||||
"all" => MakeTargets::All,
|
||||
"list" => MakeTargets::List,
|
||||
"glossaries" => MakeTargets::Glossaries,
|
||||
"clean" => MakeTargets::Clean,
|
||||
};
|
||||
|
||||
/// List all blocktype
|
||||
pub static HELP_BLOCK_SELECTION: LazyLock<String> = LazyLock::new(|| {
|
||||
let mut targets = BLOCK_PROGRESSION
|
||||
.keys()
|
||||
.map(|v| v.to_owned())
|
||||
.collect::<Vec<String>>();
|
||||
targets.sort();
|
||||
targets.join(", ").to_string()
|
||||
});
|
||||
|
||||
/// List all targets
|
||||
pub static HELP_VERBOSITY_LEVEL: LazyLock<String> = LazyLock::new(|| {
|
||||
let mut targets = STR_TO_VERBOSITY
|
||||
.values()
|
||||
.map(|v| format!("{:?}", v).to_lowercase())
|
||||
.collect::<Vec<String>>();
|
||||
targets.sort();
|
||||
targets.join(", ").to_string()
|
||||
});
|
||||
|
||||
/// List all targets
|
||||
pub static HELP_BUILD_TARGET_LIST: LazyLock<String> = LazyLock::new(|| {
|
||||
let targets = STR_TO_BUILD_TARGET
|
||||
.values()
|
||||
.map(|v| format!("{:?}", v).to_lowercase())
|
||||
.collect::<Vec<String>>();
|
||||
targets.join(", ").to_string()
|
||||
});
|
||||
|
||||
/// The verbosity level
|
||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub enum VerboseLevel {
|
||||
/// Shouldn't be printed no matter what
|
||||
None,
|
||||
/// Garbage
|
||||
Misc,
|
||||
/// Boxness, barely above Misc
|
||||
Box,
|
||||
/// Context info (Debug info)
|
||||
Context,
|
||||
/// Usefull info
|
||||
Info,
|
||||
/// Important warnings
|
||||
Warning,
|
||||
/// Errors encountered requiring user input
|
||||
Error,
|
||||
/// Uncatachable errors
|
||||
Critical,
|
||||
/// Literrally uncatchable things
|
||||
Uncatchable,
|
||||
}
|
||||
impl From<&str> for VerboseLevel {
|
||||
fn from(value: &str) -> Self {
|
||||
if let Some(target) = STR_TO_VERBOSITY.get(&value.to_lowercase()).cloned() {
|
||||
target
|
||||
} else {
|
||||
panic!(
|
||||
"Invalid debug level {}. The debug level available are (from highest verbosity to lowest): [{:?}]",
|
||||
value, HELP_VERBOSITY_LEVEL
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// All progress bar styles
|
||||
pub static BLOCK_PROGRESSION: LazyLock<HashMap<String, String>> = LazyLock::new(|| {
|
||||
let mut m = HashMap::new();
|
||||
m.insert("class".to_string(), "#>-".to_string());
|
||||
m.insert("cargo".to_string(), "#> ".to_string());
|
||||
m.insert("rough".to_string(), "█ ".to_string());
|
||||
m.insert("fine".to_string(), "█▉▊▋▌▍▎▏ ".to_string());
|
||||
m.insert("vert".to_string(), "█▇▆▅▄▃▂▁ ".to_string());
|
||||
m.insert("fade".to_string(), "█▓▒░ ".to_string());
|
||||
m.insert("block".to_string(), "█▛▌▖ ".to_string());
|
||||
m.insert("curse".to_string(), "▓▙▚▐▔ ▛▘▖▄▟▞▂█".to_string());
|
||||
m.insert("load".to_string(), " ⱠØ₳Đł₦₲ ".to_string());
|
||||
m.insert("cool".to_string(), "▰▱".to_string());
|
||||
m.insert("neo".to_string(), "▰═".to_string());
|
||||
m
|
||||
});
|
||||
// Spinners
|
||||
// ▁ ▂ ▃ ▄ ▅ ▆ ▇ █ ▇ ▆ ▅ ▄ ▃ ▁
|
||||
// ▉▊▋▌▍▎▏▎▍▌▋▊▉
|
||||
// ▖ ▘ ▝ ▗
|
||||
// ┤ ┘ ┴ └ ├ ┌ ┬ ┐
|
||||
// ◢ ◣ ◤ ◥
|
||||
// ◡◡ ⊙⊙ ◠◠
|
||||
// ⣾⣽⣻⢿⡿⣟⣯⣷ ⠁⠂⠄⡀⢀⠠⠐⠈
|
||||
// .tick_strings(&[
|
||||
// "▹▹▹▹▹",
|
||||
// "▸▹▹▹▹",
|
||||
// "▹▸▹▹▹",
|
||||
// "▹▹▸▹▹",
|
||||
// "▹▹▹▸▹",
|
||||
// "▹▹▹▹▸",
|
||||
// "▪▪▪▪▪",
|
||||
// ]),
|
||||
//
|
||||
|
||||
/// List of all alternative targets
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum MakeTargets {
|
||||
/// Make all targets
|
||||
All,
|
||||
/// Make a list of all optionals
|
||||
List,
|
||||
/// Make glossaries
|
||||
Glossaries,
|
||||
/// Make the working directory clean
|
||||
Clean,
|
||||
}
|
||||
|
||||
impl From<&str> for MakeTargets {
|
||||
fn from(value: &str) -> Self {
|
||||
if let Some(target) = STR_TO_BUILD_TARGET.get(&value.to_lowercase()).cloned() {
|
||||
target
|
||||
} else {
|
||||
panic!(
|
||||
"Invalid build target {}. The build target available are [{:?}]",
|
||||
value, HELP_BUILD_TARGET_LIST
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
// Workspace: config
|
||||
// File: config/src/statsolver.rs
|
||||
//! Statsolver Structs
|
||||
|
||||
use clap::Args;
|
||||
|
||||
#[derive(Args, Debug, Clone)]
|
||||
/// The configuration struct for the StatSolver
|
||||
pub struct StatConfig {
|
||||
// #[arg(default_value_t: "data/Book1.csv")]
|
||||
/// The path where the data to analyse is
|
||||
pub config_path: String,
|
||||
/// The verbosity level
|
||||
#[arg(short, long, default_value_t = false)]
|
||||
pub verbosity: bool,
|
||||
}
|
||||
|
|
@ -0,0 +1,99 @@
|
|||
// Workspace: config
|
||||
// File: config/src/tablegen.rs
|
||||
//! Table generation structs
|
||||
|
||||
use clap::Args;
|
||||
use phf::phf_map;
|
||||
use serde::Deserialize;
|
||||
use std::sync::LazyLock;
|
||||
|
||||
/// An enumeration representing different target types.
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum TableGenerationTarget {
|
||||
/// Processes all classes
|
||||
Classes,
|
||||
/// Processes all the craft tables
|
||||
Craft,
|
||||
/// Processes only the given files
|
||||
Files,
|
||||
/// Processes all the known targets
|
||||
All,
|
||||
}
|
||||
|
||||
impl From<&str> for TableGenerationTarget {
|
||||
fn from(value: &str) -> Self {
|
||||
if let Some(target) = STR_TO_TARGET.get(value).cloned() {
|
||||
target
|
||||
} else {
|
||||
panic!(
|
||||
"Only the following target can be used: {}",
|
||||
*HELP_STR_TO_TARGET_TABLES
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A mapping of string representations to target types.
|
||||
static STR_TO_TARGET: phf::Map<&'static str, TableGenerationTarget> = phf_map! {
|
||||
"classes" => TableGenerationTarget::Classes,
|
||||
"craft" => TableGenerationTarget::Craft,
|
||||
"files" => TableGenerationTarget::Files,
|
||||
"all" => TableGenerationTarget::All,
|
||||
};
|
||||
|
||||
/// A help of all the table targets to be built
|
||||
pub static HELP_STR_TO_TARGET_TABLES: LazyLock<String> = LazyLock::new(|| {
|
||||
let mut targets = STR_TO_TARGET
|
||||
.keys()
|
||||
.map(|v| v.to_string())
|
||||
.collect::<Vec<String>>();
|
||||
targets.sort();
|
||||
targets.join(", ").to_string()
|
||||
});
|
||||
/// Configuration options for processing TSV files and generating LaTeX tables.
|
||||
#[derive(Debug, Args)]
|
||||
pub struct TableArgs {
|
||||
/// Wether to export all files (if used), or output everything to stdout
|
||||
#[arg(short)]
|
||||
pub export: bool,
|
||||
|
||||
/// The kind of tables to operate on: classes, craft or files followed by a list of files
|
||||
// #[arg(help = format!("The kind of tables to operate on : {}", "TODO: FIX"))]
|
||||
#[arg(help = format!("The kind of tables to operate on : {}", *HELP_STR_TO_TARGET_TABLES))]
|
||||
pub kind: TableGenerationTarget,
|
||||
/// A vector of strings representing the names of TSV files to process.
|
||||
pub filenames: Vec<String>,
|
||||
}
|
||||
|
||||
// This config is can contain unconstructed code for compatibility purposes
|
||||
#[allow(dead_code)]
|
||||
#[derive(Deserialize)]
|
||||
/// The Craft configs
|
||||
pub struct Craft {
|
||||
/// The food header string formatter
|
||||
pub header_food: String,
|
||||
/// The alchemy header string formatter
|
||||
pub header_alchemy: String,
|
||||
/// The forge header string formatter
|
||||
pub header_forge: String,
|
||||
/// The mtrap header string formatter
|
||||
pub header_mtrap: String,
|
||||
/// The weapons header string formatter
|
||||
pub header_weapons: String,
|
||||
/// The armors header string formatter
|
||||
pub header_armors: String,
|
||||
/// The gadgets header string formatter
|
||||
pub header_gadgets: String,
|
||||
/// The potions header string formatter
|
||||
pub header_potions: String,
|
||||
/// The traps header string formatter
|
||||
pub header_traps: String,
|
||||
/// The table end string formatter
|
||||
pub end: String,
|
||||
/// The long table end string formatter
|
||||
pub end_long: String,
|
||||
/// The long sideways table end string formatter
|
||||
pub end_long_side: String,
|
||||
/// The no_headers table end string formatter
|
||||
pub end_empty: String,
|
||||
}
|
||||
|
|
@ -5,22 +5,10 @@ edition = "2024"
|
|||
|
||||
[dependencies]
|
||||
config = {path = "../config"}
|
||||
anyhow = "1.0.86"
|
||||
charts-rs = { version = "0.3.11" }
|
||||
clap = { version = "4.5.7", features = ["derive"] }
|
||||
console = "0.15.8"
|
||||
csv = "1.3.0"
|
||||
debug_print = "1.0.0"
|
||||
dynfmt = { version = "0.1.5", features = ["curly"] }
|
||||
glob = "0.3.1"
|
||||
indexmap = "2.2.6"
|
||||
indicatif = "0.17.8"
|
||||
logos = "0.14.0"
|
||||
phf = { version = "0.11.2", features = ["macros"] }
|
||||
regex = "1.10.5"
|
||||
regex_static = "0.1.1"
|
||||
cli_parser = {path = "../cli_parser"}
|
||||
anyhow = "1.0.95"
|
||||
charts-rs = "0.3.19"
|
||||
glob = "0.3.2"
|
||||
serde = { version = "1.0.217", features = ["derive", "alloc"] }
|
||||
csv = "1.3.1"
|
||||
ron = "0.8.1"
|
||||
serde = { version = "1.0.203", features = ["derive"] }
|
||||
serde_json = "1.0.117"
|
||||
tokio = { version = "1.38.0", features = ["full"] }
|
||||
toml = "0.8.14"
|
||||
|
|
|
|||
|
|
@ -1,19 +1,25 @@
|
|||
//! Export graphs
|
||||
//! The module `graphs` is responsible for exporting graphs based on CSV data
|
||||
//!
|
||||
//! # Usage
|
||||
//!
|
||||
//! - [`make_graphs`]: The main action dispatcher for graph generation and removal.
|
||||
|
||||
use charts_rs::{Box, Color};
|
||||
use charts_rs::{RadarChart, RadarIndicator, Series, get_or_try_init_fonts};
|
||||
use charts_rs::{Box, Color, RadarChart, RadarIndicator, Series, get_or_try_init_fonts};
|
||||
use cli_parser::Config;
|
||||
use config::{GraphConfig, GraphTargetType};
|
||||
use config::graph::{GraphConfig, GraphTargetType};
|
||||
use glob::glob;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::io::Read;
|
||||
use std::process::Command;
|
||||
use std::{fs::File, io::Write, iter};
|
||||
use std::{
|
||||
fs::File,
|
||||
io::{Read, Write},
|
||||
iter,
|
||||
process::Command,
|
||||
};
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
|
||||
/// Main action dispatch for the graph make
|
||||
pub(super) fn make_graphs(args: &GraphConfig, _config: &Config) -> Result<()> {
|
||||
pub fn make_graphs(args: &GraphConfig, _config: &Config) -> Result<()> {
|
||||
// Choose action to do
|
||||
match args.target {
|
||||
GraphTargetType::Generate => gen_graph(args),
|
||||
|
|
@ -1,14 +1,9 @@
|
|||
pub fn add(left: u64, right: u64) -> u64 {
|
||||
left + right
|
||||
}
|
||||
//! This workspace_crate is a Rust library designed to create and manage graphs based on CSV (Comma-Separated Values) data.
|
||||
//!
|
||||
//!
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn it_works() {
|
||||
let result = add(2, 2);
|
||||
assert_eq!(result, 4);
|
||||
}
|
||||
}
|
||||
// Internal modules
|
||||
mod graphs;
|
||||
//
|
||||
// Re Export
|
||||
pub use graphs::make_graphs;
|
||||
|
|
|
|||
|
|
@ -5,22 +5,14 @@ edition = "2024"
|
|||
|
||||
[dependencies]
|
||||
config = {path = "../config"}
|
||||
anyhow = "1.0.86"
|
||||
charts-rs = { version = "0.3.11" }
|
||||
clap = { version = "4.5.7", features = ["derive"] }
|
||||
console = "0.15.8"
|
||||
csv = "1.3.0"
|
||||
debug_print = "1.0.0"
|
||||
cli_parser = {path = "../cli_parser"}
|
||||
dynfmt = { version = "0.1.5", features = ["curly"] }
|
||||
glob = "0.3.1"
|
||||
indexmap = "2.2.6"
|
||||
indicatif = "0.17.8"
|
||||
logos = "0.14.0"
|
||||
phf = { version = "0.11.2", features = ["macros"] }
|
||||
regex = "1.10.5"
|
||||
regex_static = "0.1.1"
|
||||
ron = "0.8.1"
|
||||
serde = { version = "1.0.203", features = ["derive"] }
|
||||
serde_json = "1.0.117"
|
||||
tokio = { version = "1.38.0", features = ["full"] }
|
||||
toml = "0.8.14"
|
||||
indicatif = { version = "0.17.11", features = ["rayon"] }
|
||||
logos = "0.15.0"
|
||||
tokio = "1.43.0"
|
||||
anyhow = "1.0.95"
|
||||
indexmap = "2.7.1"
|
||||
regex = "1.11.1"
|
||||
serde = { version = "1.0.217", features = ["derive", "alloc"] }
|
||||
console = "0.15.10"
|
||||
toml = "0.8.20"
|
||||
|
|
|
|||
|
|
@ -1,14 +1,28 @@
|
|||
pub fn add(left: u64, right: u64) -> u64 {
|
||||
left + right
|
||||
}
|
||||
// Workspace: make
|
||||
// File: make/src/lib.rs
|
||||
//! The module `makepdf` is responsible for making a pdf using pdflatex.
|
||||
//!
|
||||
//! The main function, [`make_pdf`](crate::makepdf::make_pdf), orchestrates the entire process of preparing,
|
||||
//! building, and cleaning up LaTeX files to produce a final PDF. It relies on several other modules
|
||||
//! within the `makepdf` workspace to perform specific tasks.
|
||||
//!
|
||||
//! This module contains various helper functions used in the main build process.
|
||||
//!
|
||||
//! It provides utilities for checking and adding input lines based on specified conditions,
|
||||
//! generating glossaries, and managing temporary files. These functions are essential for ensuring
|
||||
//! that the LaTeX files are correctly prepared before invoking pdflatex to generate the final PDF.
|
||||
//!
|
||||
//! Contains utility data types used by other modules in the `makepdf` workspace.
|
||||
//!
|
||||
//! This module is responsible for defining the necessary data structures and traits that are shared
|
||||
//! across different parts of the build process. It includes items such as enums, structs, and traits
|
||||
//! that help in organizing and managing the various components involved in creating a PDF from LaTeX files.
|
||||
//!
|
||||
// Internal modules
|
||||
mod makepdf;
|
||||
mod makepdf_functions;
|
||||
mod makepdf_misc;
|
||||
mod makepdf_structs;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn it_works() {
|
||||
let result = add(2, 2);
|
||||
assert_eq!(result, 4);
|
||||
}
|
||||
}
|
||||
// Re Export
|
||||
pub use makepdf::make_pdf;
|
||||
|
|
|
|||
|
|
@ -1,22 +1,37 @@
|
|||
//! Make a pdf using pdflatex
|
||||
// Workspace: make
|
||||
// File: make/src/makepdf.rs
|
||||
//! The module `makepdf_functions` is responsible for making a pdf using pdflatex.
|
||||
//!
|
||||
//!
|
||||
//! # Usage
|
||||
//!
|
||||
//! - [make_pdf]: Make a pdf spawning a subprocess
|
||||
//!
|
||||
//! # Functions
|
||||
//!
|
||||
//! - `launch_subprocess`: Launches the subprocess to make the pdf
|
||||
//! - `checkline`: Checks each line of the subprocess output and updates the status accordingly
|
||||
//!
|
||||
|
||||
use std::time::{Duration, Instant};
|
||||
// use std::str::pattern::Pattern;
|
||||
use std::fmt::Write;
|
||||
use config::make::{BLOCK_PROGRESSION, HELP_BLOCK_SELECTION, MakeTargets, VerboseLevel};
|
||||
use std::{
|
||||
fmt::Write,
|
||||
process::Stdio,
|
||||
str,
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
|
||||
use cli_parser::MakeConfig;
|
||||
use config::{BLOCK_PROGRESSION, HELP_BLOCK_SELECTION, MakeTargets, VerboseLevel};
|
||||
use cli_parser::{Config, MakeConfig};
|
||||
use dynfmt::FormatArgs;
|
||||
use indicatif::{ProgressBar, ProgressState, ProgressStyle};
|
||||
use logos::Logos;
|
||||
use std::str;
|
||||
use tokio::io::{AsyncBufReadExt, BufReader};
|
||||
use tokio::process::Command;
|
||||
use tokio::{
|
||||
io::{AsyncBufReadExt, BufReader},
|
||||
process::Command,
|
||||
};
|
||||
|
||||
use anyhow::{Result, anyhow};
|
||||
use std::process::Stdio;
|
||||
|
||||
use crate::Config;
|
||||
use crate::makepdf_functions::{
|
||||
BuilderParseResult, make_clean, make_file, make_glossaries, make_list,
|
||||
};
|
||||
|
|
@ -26,7 +41,7 @@ use crate::makepdf_structs::{
|
|||
};
|
||||
|
||||
/// Make a pdf spawning a subprocess
|
||||
pub(super) fn make_pdf(args: &MakeConfig, _config: &Config) -> Result<()> {
|
||||
pub fn make_pdf(args: &MakeConfig, _config: &Config) -> Result<()> {
|
||||
let Ok(Some(_)) = BLOCK_PROGRESSION.get_key(&args.pbar) else {
|
||||
panic!(
|
||||
"Progressbar {} doesn't exists. Use one of the following [{:?}]",
|
||||
|
|
@ -1,4 +1,11 @@
|
|||
//! Helper functions
|
||||
// Workspace: make
|
||||
// File: make/src/makepdf_functions.rs
|
||||
//! The module `makepdf_functions` is a collection of helper functions used in the main build process.
|
||||
//!
|
||||
//! It provides various utilities for preparing, building, and cleaning up LaTeX files.
|
||||
//! These functions are primarily responsible for checking and adding input lines based
|
||||
//! on specified conditions, generating glossaries, and managing temporary files.
|
||||
//!
|
||||
use std::{
|
||||
fs::File,
|
||||
io::{Read, Write},
|
||||
|
|
@ -1,6 +1,9 @@
|
|||
//! Holds all the structs for the makepdf module
|
||||
// Workspace: make
|
||||
// File: make/src/makepdf_structs.rs
|
||||
//! Contains utility data types used by other modules in the `makepdf` workspace.
|
||||
//!
|
||||
use cli_parser::MakeConfig;
|
||||
use config::VerboseLevel;
|
||||
use config::make::VerboseLevel;
|
||||
use logos::Logos;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{
|
||||
|
|
@ -7,26 +7,23 @@ edition = "2024"
|
|||
[dependencies]
|
||||
tablegen = {path = "../tablegen"}
|
||||
graphs = {path = "../graphs"}
|
||||
make = {path = "../make"}
|
||||
cli_parser = {path = "../cli_parser"}
|
||||
config = {path = "../config"}
|
||||
stats = {path = "../stats"}
|
||||
make = {path = "../make"}
|
||||
|
||||
anyhow = "1.0.86"
|
||||
charts-rs = { version = "0.3.11" }
|
||||
clap = { version = "4.5.7", features = ["derive"] }
|
||||
console = "0.15.8"
|
||||
csv = "1.3.0"
|
||||
debug_print = "1.0.0"
|
||||
anyhow = "1.0.95"
|
||||
charts-rs = { version = "0.3.19" }
|
||||
clap = { version = "4.5.28", features = ["derive"] }
|
||||
console = "0.15.10"
|
||||
csv = "1.3.1"
|
||||
dynfmt = { version = "0.1.5", features = ["curly"] }
|
||||
glob = "0.3.1"
|
||||
indexmap = "2.2.6"
|
||||
indicatif = "0.17.8"
|
||||
logos = "0.14.0"
|
||||
phf = { version = "0.11.2", features = ["macros"] }
|
||||
regex = "1.10.5"
|
||||
regex_static = "0.1.1"
|
||||
glob = "0.3.2"
|
||||
indexmap = "2.7.1"
|
||||
indicatif = "0.17.11"
|
||||
logos = "0.15.0"
|
||||
regex = "1.11.1"
|
||||
ron = "0.8.1"
|
||||
serde = { version = "1.0.203", features = ["derive"] }
|
||||
serde_json = "1.0.117"
|
||||
tokio = { version = "1.38.0", features = ["full"] }
|
||||
toml = "0.8.14"
|
||||
serde = { version = "1.0.217", features = ["derive"] }
|
||||
tokio = { version = "1.43.0", features = ["full"] }
|
||||
toml = "0.8.20"
|
||||
|
|
|
|||
|
|
@ -2,34 +2,23 @@
|
|||
//!
|
||||
//! This program is meant as a helper for the ravenous project.
|
||||
//!
|
||||
|
||||
#![warn(missing_docs)]
|
||||
#![warn(clippy::missing_docs_in_private_items)]
|
||||
mod graphs;
|
||||
mod makepdf;
|
||||
mod makepdf_functions;
|
||||
mod makepdf_misc;
|
||||
mod makepdf_structs;
|
||||
mod stat_algo;
|
||||
mod stat_io;
|
||||
mod stat_structs;
|
||||
mod stats;
|
||||
|
||||
// Workspace
|
||||
use graphs::make_graphs;
|
||||
use make::make_pdf;
|
||||
use stats::stat_solver;
|
||||
use tablegen::table_gen;
|
||||
|
||||
// External imports
|
||||
use anyhow::{Context, Result};
|
||||
use clap::Parser;
|
||||
// mod table_structs;
|
||||
// mod table_types;
|
||||
// mod tablegen;
|
||||
use cli_parser::{Commands, Config, ConfigArgs, ParserCLIArgs};
|
||||
use std::{
|
||||
fs::{self, OpenOptions},
|
||||
io::Write,
|
||||
};
|
||||
use tablegen::table_gen;
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
use graphs::make_graphs;
|
||||
use makepdf::make_pdf;
|
||||
use stats::stat_solver;
|
||||
|
||||
fn main() -> Result<()> {
|
||||
let args = ParserCLIArgs::parse();
|
||||
|
|
|
|||
|
|
@ -5,22 +5,8 @@ edition = "2024"
|
|||
|
||||
[dependencies]
|
||||
config = {path = "../config"}
|
||||
anyhow = "1.0.86"
|
||||
charts-rs = { version = "0.3.11" }
|
||||
clap = { version = "4.5.7", features = ["derive"] }
|
||||
console = "0.15.8"
|
||||
csv = "1.3.0"
|
||||
cli_parser = {path = "../cli_parser"}
|
||||
anyhow = "1.0.95"
|
||||
csv = "1.3.1"
|
||||
debug_print = "1.0.0"
|
||||
dynfmt = { version = "0.1.5", features = ["curly"] }
|
||||
glob = "0.3.1"
|
||||
indexmap = "2.2.6"
|
||||
indicatif = "0.17.8"
|
||||
logos = "0.14.0"
|
||||
phf = { version = "0.11.2", features = ["macros"] }
|
||||
regex = "1.10.5"
|
||||
regex_static = "0.1.1"
|
||||
ron = "0.8.1"
|
||||
serde = { version = "1.0.203", features = ["derive"] }
|
||||
serde_json = "1.0.117"
|
||||
tokio = { version = "1.38.0", features = ["full"] }
|
||||
toml = "0.8.14"
|
||||
serde = { version = "1.0.217", features = ["derive"] }
|
||||
|
|
|
|||
|
|
@ -1,14 +1,20 @@
|
|||
pub fn add(left: u64, right: u64) -> u64 {
|
||||
left + right
|
||||
}
|
||||
// Workspace: stats
|
||||
// File: stats/src/lib.rs
|
||||
//! The `stats` crate provides tools for managing and solving statistical affinity problems in creatures.
|
||||
//!
|
||||
//! This module serves as the entry point to all functionality provided by the `stats` crate.
|
||||
//!
|
||||
//! # Submodules
|
||||
//!
|
||||
//! - `stat_algo`: Contains algorithms for finding solutions to the statistics problem.
|
||||
//! - `stat_structs`: Defines data structures used for managing statistical weights and matrix operations.
|
||||
//! - `stat_io`: Handles input/output operations, such as loading stat records from configuration files.
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
// Internal modules
|
||||
mod stat_algo;
|
||||
mod stat_io;
|
||||
mod stat_structs;
|
||||
mod stats;
|
||||
|
||||
#[test]
|
||||
fn it_works() {
|
||||
let result = add(2, 2);
|
||||
assert_eq!(result, 4);
|
||||
}
|
||||
}
|
||||
// Re Export
|
||||
pub use stats::stat_solver;
|
||||
|
|
|
|||
|
|
@ -1,10 +1,16 @@
|
|||
//! The stat repartition algorithm
|
||||
// Workspace: stats
|
||||
// File: stats/src/stat_algo.rs
|
||||
//! The module `stat_algo` contains algorithms for solving statistical affinity problems.
|
||||
|
||||
//! # Usage
|
||||
//!
|
||||
//! - [find_all_fits]: Searches for all fits of a given mode in the character matrix and adds them to the solution.
|
||||
|
||||
use crate::{
|
||||
stat_io::{AffName, CharacCharMatrix},
|
||||
stat_structs::Fit,
|
||||
};
|
||||
use anyhow::{anyhow, Result};
|
||||
use anyhow::{Result, anyhow};
|
||||
use debug_print::debug_println;
|
||||
use std::{iter::Cycle, vec::IntoIter};
|
||||
|
||||
|
|
@ -47,8 +53,9 @@ pub(super) fn find_all_fits(
|
|||
}
|
||||
} else {
|
||||
return Err(anyhow!(
|
||||
"Can't find any ({:?}) fit at any level, please examine the remaining unfitted characters"
|
||||
,mode));
|
||||
"Can't find any ({:?}) fit at any level, please examine the remaining unfitted characters",
|
||||
mode
|
||||
));
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
|
@ -1,8 +1,13 @@
|
|||
//! All the struct needed for IO purposes
|
||||
// Workspace: stats
|
||||
// File: stats/src/stat_io.rs
|
||||
//! The module `CharacStatMatrix` allows for manipulation of creatures and their associated affinities.
|
||||
//! It provides a structured way to add, manage, and retrieve information about creatures based on
|
||||
//! different affinity statistics.
|
||||
//!
|
||||
use crate::{stat_algo::Mode, stat_structs::Fit};
|
||||
use anyhow::anyhow;
|
||||
use anyhow::{Context, Result};
|
||||
use config::StatConfig;
|
||||
use config::statsolver::StatConfig;
|
||||
use csv::StringRecord;
|
||||
use debug_print::debug_println;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
|
@ -1,4 +1,8 @@
|
|||
//! Stats repartition structs
|
||||
// Workspace: stats
|
||||
// File: stats/src/stats_structs.rs
|
||||
//! The module `stats_repartition` handles the repartition of stats on creatures.
|
||||
//! It includes structs and methods for managing the fitness of a solution and the
|
||||
//! weights of different affinities
|
||||
|
||||
use std::{iter::Cycle, vec::IntoIter};
|
||||
|
||||
|
|
@ -1,19 +1,28 @@
|
|||
//! A module to handle stats disparity between all origins
|
||||
|
||||
// Workspace: stats
|
||||
// File: stats/src/stats.rs
|
||||
//! The module `stats` handles stats disparity between all origins
|
||||
//!
|
||||
//! # Usage
|
||||
//!
|
||||
//! - [stat_solver]: Main solver function, in charge of selecting algorithms and handling all program flow
|
||||
//!
|
||||
//! It consists of several submodules:
|
||||
//!
|
||||
//! - `stat_algo`: Contains the algorithm implementations for finding solutions to the statistics problem.
|
||||
//! - `stat_structs`: Defines data structures used for managing statistical weights and matrix operations.
|
||||
//! - `stat_io`: Handles input/output operations, such as loading stat records from configuration files.
|
||||
use crate::{
|
||||
stat_algo::{Mode, find_all_fits},
|
||||
stat_structs::StatWeightList,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
Config,
|
||||
stat_io::{AffName, CharacCharMatrix, load_stat_records},
|
||||
};
|
||||
use crate::stat_io::{AffName, CharacCharMatrix, load_stat_records};
|
||||
use anyhow::Result;
|
||||
use config::StatConfig;
|
||||
use cli_parser::Config;
|
||||
use config::statsolver::StatConfig;
|
||||
|
||||
/// Main solver function, in charge of selecting algorithms and handling all program flow
|
||||
pub(super) fn stat_solver(args: &StatConfig, config: &Config) -> Result<()> {
|
||||
pub fn stat_solver(args: &StatConfig, config: &Config) -> Result<()> {
|
||||
let _ = config;
|
||||
let mut statmatrix = load_stat_records(&args.config_path, args.clone()).unwrap();
|
||||
solution_from_empty(&mut statmatrix).unwrap();
|
||||
|
|
@ -7,7 +7,6 @@ edition = "2024"
|
|||
cli_parser = {path = "../cli_parser"}
|
||||
config = {path = "../config"}
|
||||
anyhow = "1.0.95"
|
||||
clap = { version = "4.5.28", features = ["derive"] }
|
||||
csv = "1.3.1"
|
||||
dynfmt = { version = "0.1.5", features = ["curly"] }
|
||||
glob = "0.3.2"
|
||||
|
|
|
|||
|
|
@ -1,7 +1,27 @@
|
|||
//! The tsv table generation
|
||||
|
||||
// Workspace: tablegen
|
||||
// File: tablegen/src/lib.rs
|
||||
//! This is a library for generating LaTeX tables from TSV files.
|
||||
//!
|
||||
//! The main entry point of this library is the `table_gen` function, which takes in configuration arguments and a config object,
|
||||
//! then processes the specified files according to their type (classes, craft, etc.).
|
||||
//! If an error occurs during processing, it will be reported via a Result.
|
||||
//!
|
||||
//! This library consists of several modules:
|
||||
//!
|
||||
//! - `table_structs`: Defines the structure and behavior of tables. It includes types like `RecordClass` representing
|
||||
//! a class record in a TSV file and `ClassesArray` holding all the data for classes.
|
||||
//! - `table_types`: Contains types related to TSV files and LaTeX code generation.
|
||||
//! It provides structures like `GenericArray` for creating tables based on generic records,
|
||||
//! and utility types like `CleanString` for handling string formatting specific to LaTeX tables.
|
||||
//! - `tablegen`: Contatining the whole logic behind the table generation
|
||||
//!
|
||||
//! The following functions are re-exported from the module `tablegen`:
|
||||
//!
|
||||
//! - [`table_gen`]: Handling the whole conversion and auto dispatch.
|
||||
mod table_structs;
|
||||
mod table_types;
|
||||
mod tablegen;
|
||||
use cli_parser::Config;
|
||||
|
||||
// Reexport
|
||||
pub use tablegen::table_gen;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
//! Holds all the data structures away from the main routine
|
||||
// Workspace: tablegen
|
||||
// File: tablegen/src/table_structs.rs
|
||||
//! The module `table_structs` contains the base structs needed for the tablegen to function.
|
||||
use phf::phf_map;
|
||||
use regex::Regex;
|
||||
use regex_static::once_cell::sync::Lazy;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,16 @@
|
|||
//! Holds all the table base structure
|
||||
// Workspace: tablegen
|
||||
// File: tablegen/src/table_types.rs
|
||||
//! This module provides functionality for creating LaTeX tables based on data extracted from TSV files.
|
||||
//!
|
||||
//! It consists of several main components:
|
||||
//!
|
||||
//! - `RecordClass`: Represents a single row in a martial class TSV file and implements the `WriteRow` trait for writing table rows.
|
||||
//! - `ClassesArray`: Holds all the data for classes and provides methods to write the entire table as a string.
|
||||
//! - `GenericArray<RecordType>`: A generic structure for holding any type of records that implement the `WriteRow` trait and can be written as a LaTeX table.
|
||||
//! - `StringRecord`: Represents a row in a TSV file as a vector of strings.
|
||||
//!
|
||||
//! The module also includes utility types like `CleanString` for handling string formatting specific to LaTeX tables.
|
||||
|
||||
use crate::{Config, table_structs::TableTargets, tablegen::make_latex_string};
|
||||
use anyhow::{Context, Result};
|
||||
use csv::StringRecord;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,33 @@
|
|||
//! The tsv table generation
|
||||
// Workspace: tablegen
|
||||
// File: tablegen/src/tablegen.rs
|
||||
//! The tsv table generation module contains functionalities to read, convert and export TSV files.
|
||||
//!
|
||||
//! This module provides functionality for reading a tab-separated values (TSV) file into a table structure,
|
||||
//! converting the table data into LaTeX code, and exporting the resulting code as a string or writing it to a file.
|
||||
//!
|
||||
//! # Usage
|
||||
//!
|
||||
//! The `table_gen` function is the main entry point of this module. It takes in configuration arguments and a
|
||||
//! config object, then processes the specified files according to their type (classes, craft, etc.). If an error occurs during processing,
|
||||
//! it will be reported via a Result. For more information on each function's usage, see the respective sections below.
|
||||
//!
|
||||
//! # Functions
|
||||
//!
|
||||
//! - [`table_gen`]: Generates the tables for the specified files.
|
||||
//! - [`process_files`]: Processes any type of file, one by one and calls the right converter function.
|
||||
//! - [`export_tsv`]: Converts a TSV file to LaTeX code.
|
||||
//! - [`make_latex_string`]: Replaces all instances of unrepresentable utf8 or non escaped characters with latex ones.
|
||||
//! - [`read_tsv_classes`]: Reads a TSV file into a table for classes.
|
||||
//! - [`read_generic_tsv`]: Reads a TSV file into a table for generic types.
|
||||
//! - [`tsv_to_string`]: Converts a table of data into a string representation.
|
||||
//!
|
||||
//! # Submodules
|
||||
//!
|
||||
//! This module consists of several submodules:
|
||||
//! - `table_structs`: Defines the structure and behavior of tables.
|
||||
//! - `table_types`: Contains types related to TSV files and LaTeX code generation.
|
||||
use anyhow::{Context, Result};
|
||||
use config::{TableArgs, TableGenerationTarget};
|
||||
use config::tablegen::{TableArgs, TableGenerationTarget};
|
||||
use glob::glob;
|
||||
use regex::Captures;
|
||||
use std::{
|
||||
|
|
|
|||
Loading…
Reference in New Issue