Skip to main content

lib/
fn_pathtype.rs

1// src/lib/fn_fileslang.rs
2
3/// Struktura przechowująca metadane dla danego typu pliku
4pub struct PathFileType {
5    pub icon: &'static str,
6    pub md_lang: &'static str,
7}
8/// SSoT dla ikony folderu
9pub const DIR_ICON: &str = "📂";
10
11/// SSoT (Single Source of Truth) dla rozszerzeń plików.
12/// Zwraca odpowiednią ikonę do drzewa ASCII oraz język formatowania Markdown.
13pub fn get_file_type(ext: &str) -> PathFileType {
14    match ext {
15        "rs" => PathFileType {
16            icon: "🦀",
17            md_lang: "rust",
18        },
19        "toml" => PathFileType {
20            icon: "⚙️",
21            md_lang: "toml",
22        },
23        "slint" => PathFileType {
24            icon: "🎨",
25            md_lang: "slint",
26        },
27        "md" => PathFileType {
28            icon: "📝",
29            md_lang: "markdown",
30        },
31        "json" => PathFileType {
32            icon: "🔣",
33            md_lang: "json",
34        },
35        "yaml" | "yml" => PathFileType {
36            icon: "🛠️",
37            md_lang: "yaml",
38        },
39        "html" => PathFileType {
40            icon: "🌐",
41            md_lang: "html",
42        },
43        "css" => PathFileType {
44            icon: "🖌️",
45            md_lang: "css",
46        },
47        "js" => PathFileType {
48            icon: "📜",
49            md_lang: "javascript",
50        },
51        "ts" => PathFileType {
52            icon: "📘",
53            md_lang: "typescript",
54        },
55        _ => PathFileType {
56            icon: "📄",
57            md_lang: "text",
58        }, // Domyślny fallback
59    }
60}