Removed nearly all phf references
This commit is contained in:
parent
a168fa196e
commit
6a1e9d323f
|
|
@ -38,7 +38,6 @@ fast_class = {path = "./crates/fast_class"}
|
|||
anyhow = "1.0.100"
|
||||
toml = "0.9.11"
|
||||
clap = { version = "4.5.54", features = ["derive"] }
|
||||
phf = { version = "0.13.1", features = ["macros"] }
|
||||
regex = "1.12.2"
|
||||
regex_static = "0.1.1"
|
||||
serde = { version = "1.0.228", features = ["derive", "alloc"] }
|
||||
|
|
@ -47,5 +46,3 @@ ron = "0.12.0"
|
|||
glob = "0.3.3"
|
||||
tokio = "1.49.0"
|
||||
dynfmt = { version = "0.1.5", features = ["curly"] }
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -6,10 +6,7 @@ use clap::{Args, Parser, Subcommand};
|
|||
use config::{
|
||||
fast_tables::FastTableConfig,
|
||||
graph::GraphConfig,
|
||||
make::{
|
||||
HELP_BLOCK_SELECTION, HELP_BUILD_TARGET_LIST, HELP_VERBOSITY_LEVEL, MakeTargets,
|
||||
VerboseLevel,
|
||||
},
|
||||
make::{HELP_BLOCK_SELECTION, MakeTargets, VerboseLevel},
|
||||
statsolver::StatConfig,
|
||||
tablegen::{Craft, TableArgs},
|
||||
};
|
||||
|
|
@ -84,21 +81,18 @@ pub struct Classes {
|
|||
pub end: String,
|
||||
}
|
||||
|
||||
// The make structs
|
||||
|
||||
#[derive(Args, Debug, Clone)]
|
||||
// #[command(after_)]
|
||||
/// The configuration struct for the PdfMaker
|
||||
pub struct MakeConfig {
|
||||
/// The filename to compile
|
||||
pub filename: String,
|
||||
|
||||
/// Special target
|
||||
#[arg(short, long, help = format!("Build with a special target. [{}]", HELP_BUILD_TARGET_LIST.as_str()))]
|
||||
#[arg(short, long)]
|
||||
pub target: Option<MakeTargets>,
|
||||
|
||||
/// The verbosity level
|
||||
#[arg(short, long, default_value = "warning", help = format!("The verbosity level. [{}]",HELP_VERBOSITY_LEVEL.as_str()))]
|
||||
#[arg(short, long, default_value = "warning")]
|
||||
pub verbosity: VerboseLevel,
|
||||
|
||||
/// The progress bar style
|
||||
|
|
|
|||
|
|
@ -5,5 +5,4 @@ edition = "2024"
|
|||
|
||||
[dependencies]
|
||||
clap = {workspace = true}
|
||||
phf = {workspace = true}
|
||||
serde = {workspace = true}
|
||||
|
|
|
|||
|
|
@ -2,15 +2,12 @@
|
|||
// File: config/src/graph.rs
|
||||
//! The inner config for graph module
|
||||
//!
|
||||
use clap::Args;
|
||||
use phf::phf_map;
|
||||
use std::sync::LazyLock;
|
||||
use clap::{Args, ValueEnum};
|
||||
|
||||
#[derive(Args, Debug, Clone)]
|
||||
/// The configuration struct for the Graph
|
||||
pub struct GraphConfig {
|
||||
/// Special target
|
||||
#[arg(help = format!("The target to execute [{}]", *HELP_STR_TO_GRAPH))]
|
||||
pub target: GraphTargetType,
|
||||
|
||||
/// Alternative origin
|
||||
|
|
@ -30,25 +27,7 @@ pub struct GraphConfig {
|
|||
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
|
||||
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)]
|
||||
#[derive(ValueEnum, Debug, Clone)]
|
||||
/// All target type
|
||||
pub enum GraphTargetType {
|
||||
/// Make all graphs
|
||||
|
|
@ -58,15 +37,3 @@ pub enum GraphTargetType {
|
|||
/// 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
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,28 +2,9 @@
|
|||
// File: config/src/make.rs
|
||||
//! Makepdf generation structs
|
||||
|
||||
use phf::phf_map;
|
||||
use clap::ValueEnum;
|
||||
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
|
||||
|
|
@ -34,27 +15,8 @@ pub static HELP_BLOCK_SELECTION: LazyLock<String> = LazyLock::new(|| {
|
|||
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)]
|
||||
#[derive(ValueEnum, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub enum VerboseLevel {
|
||||
/// Shouldn't be printed no matter what
|
||||
None,
|
||||
|
|
@ -70,23 +32,11 @@ pub enum VerboseLevel {
|
|||
Warning,
|
||||
/// Errors encountered requiring user input
|
||||
Error,
|
||||
/// Uncatachable errors
|
||||
/// Uncatchable 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(|| {
|
||||
|
|
@ -104,27 +54,9 @@ pub static BLOCK_PROGRESSION: LazyLock<HashMap<String, String>> = LazyLock::new(
|
|||
m.insert("neo".to_string(), "▰═".to_string());
|
||||
m
|
||||
});
|
||||
// Spinners
|
||||
// ▁ ▂ ▃ ▄ ▅ ▆ ▇ █ ▇ ▆ ▅ ▄ ▃ ▁
|
||||
// ▉▊▋▌▍▎▏▎▍▌▋▊▉
|
||||
// ▖ ▘ ▝ ▗
|
||||
// ┤ ┘ ┴ └ ├ ┌ ┬ ┐
|
||||
// ◢ ◣ ◤ ◥
|
||||
// ◡◡ ⊙⊙ ◠◠
|
||||
// ⣾⣽⣻⢿⡿⣟⣯⣷ ⠁⠂⠄⡀⢀⠠⠐⠈
|
||||
// .tick_strings(&[
|
||||
// "▹▹▹▹▹",
|
||||
// "▸▹▹▹▹",
|
||||
// "▹▸▹▹▹",
|
||||
// "▹▹▸▹▹",
|
||||
// "▹▹▹▸▹",
|
||||
// "▹▹▹▹▸",
|
||||
// "▪▪▪▪▪",
|
||||
// ]),
|
||||
//
|
||||
|
||||
/// List of all alternative targets
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(ValueEnum, Debug, Clone)]
|
||||
pub enum MakeTargets {
|
||||
/// Make all targets
|
||||
All,
|
||||
|
|
@ -135,16 +67,3 @@ pub enum MakeTargets {
|
|||
/// 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
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,13 +2,11 @@
|
|||
// File: config/src/tablegen.rs
|
||||
//! Table generation structs
|
||||
|
||||
use clap::Args;
|
||||
use phf::phf_map;
|
||||
use clap::{Args, ValueEnum};
|
||||
use serde::Deserialize;
|
||||
use std::sync::LazyLock;
|
||||
|
||||
/// An enumeration representing different target types.
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(ValueEnum, Debug, Clone)]
|
||||
pub enum TableGenerationTarget {
|
||||
/// Processes all classes
|
||||
Classes,
|
||||
|
|
@ -20,36 +18,6 @@ pub enum TableGenerationTarget {
|
|||
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
|
||||
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 {
|
||||
|
|
@ -58,8 +26,6 @@ pub struct TableArgs {
|
|||
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>,
|
||||
|
|
|
|||
|
|
@ -10,7 +10,9 @@ anyhow = {workspace = true}
|
|||
csv = {workspace = true}
|
||||
dynfmt = {workspace = true}
|
||||
glob = {workspace = true}
|
||||
phf = {workspace = true}
|
||||
regex = {workspace = true}
|
||||
regex_static = {workspace = true}
|
||||
serde = {workspace = true}
|
||||
clap = {workspace = true}
|
||||
phf = { version = "0.13.1", features = ["macros"] }
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue