From 8a43eb81b56d5602b33f3a6be7629c32144d37ab Mon Sep 17 00:00:00 2001 From: 7000pctAUTO Date: Wed, 4 Feb 2026 04:43:19 +0000 Subject: [PATCH] Initial upload: gitignore-gen Rust CLI tool with 100+ templates --- app/gitignore-gen/src/templates/models.rs | 163 ++++++++++++++++++++++ 1 file changed, 163 insertions(+) create mode 100644 app/gitignore-gen/src/templates/models.rs diff --git a/app/gitignore-gen/src/templates/models.rs b/app/gitignore-gen/src/templates/models.rs new file mode 100644 index 0000000..e23b42c --- /dev/null +++ b/app/gitignore-gen/src/templates/models.rs @@ -0,0 +1,163 @@ +use serde::{Deserialize, Serialize}; +use std::collections::HashSet; +use std::hash::{Hash, Hasher}; + +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] +pub struct Template { + pub name: String, + pub category: Category, + pub patterns: Vec, + pub description: Option, + pub version: Option, + pub author: Option, + pub url: Option, +} + +impl Template { + pub fn new(name: String, category: Category, patterns: Vec) -> Self { + Self { + name, + category, + patterns, + description: None, + version: None, + author: None, + url: None, + } + } + + pub fn with_description(mut self, description: String) -> Self { + self.description = Some(description); + self + } + + pub fn with_version(mut self, version: String) -> Self { + self.version = Some(version); + self + } + + pub fn patterns_as_string(&self) -> String { + self.patterns.join("\n") + } +} + +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)] +pub enum Category { + Language, + Framework, + IDE, + Editor, + BuildTool, + OS, + Database, + VersionControl, + Documentation, + Testing, + Misc, + Custom(String), +} + +impl std::fmt::Display for Category { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Category::Language => write!(f, "Language"), + Category::Framework => write!(f, "Framework"), + Category::IDE => write!(f, "IDE"), + Category::Editor => write!(f, "Editor"), + Category::BuildTool => write!(f, "Build Tool"), + Category::OS => write!(f, "Operating System"), + Category::Database => write!(f, "Database"), + Category::VersionControl => write!(f, "Version Control"), + Category::Documentation => write!(f, "Documentation"), + Category::Testing => write!(f, "Testing"), + Category::Misc => write!(f, "Miscellaneous"), + Category::Custom(s) => write!(f, "{}", s), + } + } +} + +#[derive(Debug, Clone)] +pub struct TemplateSet { + pub templates: Vec