Adds doc
This commit is contained in:
parent
18cc6cd48e
commit
c4a6c50951
|
|
@ -9,6 +9,7 @@ edition = "2021"
|
|||
[dependencies]
|
||||
clap = { version = "4.5.4", features = ["derive"] }
|
||||
csv = "1.3.0"
|
||||
phf = { version = "0.11.2", features = ["macros"] }
|
||||
regex = "1.10.4"
|
||||
serde = { version = "1.0.198", features = ["derive"] }
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
//! The csv table generation
|
||||
use clap::Args;
|
||||
use phf::phf_map;
|
||||
use serde::Deserialize;
|
||||
use std::io::{Error, Write};
|
||||
use std::path::Path;
|
||||
|
|
@ -13,12 +14,43 @@ pub struct TableArgs {
|
|||
#[arg(short)]
|
||||
export: bool,
|
||||
|
||||
// #[arg(shorl, long)]
|
||||
// type:
|
||||
/// The kind of tables to operate on: classes, craft or a specific file
|
||||
kind: TargetType,
|
||||
/// A vector of strings representing the names of CSV files to process.
|
||||
filenames: Vec<String>,
|
||||
}
|
||||
|
||||
/// An enumeration representing different target types.
|
||||
#[derive(Debug, Clone)]
|
||||
enum TargetType {
|
||||
/// Processes all classes
|
||||
Classes,
|
||||
/// Processes all the craft tables
|
||||
Craft,
|
||||
/// Processes only the given files
|
||||
Files,
|
||||
}
|
||||
|
||||
/// A mapping of string representations to target types.
|
||||
static STR_TO_TARGET: phf::Map<&'static str, TargetType> = phf_map! {
|
||||
"classes" => TargetType::Classes,
|
||||
"craft" => TargetType::Craft,
|
||||
"files" => TargetType::Files,
|
||||
};
|
||||
|
||||
impl From<&str> for TargetType {
|
||||
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: {:?}",
|
||||
STR_TO_TARGET.keys()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(rename_all = "PascalCase")]
|
||||
/// A single row in a martial class csv file
|
||||
|
|
|
|||
Loading…
Reference in New Issue