sakurs_cli/
language_source.rs

1//! Language source management for CLI
2
3use crate::commands::process::Language;
4use std::path::PathBuf;
5
6/// Source of language rules
7#[derive(Debug, Clone)]
8pub enum LanguageSource {
9    /// Built-in language (existing behavior)
10    BuiltIn(Language),
11    /// External configuration file
12    External {
13        /// Path to the configuration file
14        path: PathBuf,
15        /// Optional language code override
16        language_code: Option<String>,
17    },
18}
19
20impl LanguageSource {
21    /// Get the display name for the language source
22    pub fn display_name(&self) -> String {
23        match self {
24            LanguageSource::BuiltIn(lang) => format!("Built-in: {}", lang.as_str()),
25            LanguageSource::External {
26                path,
27                language_code,
28            } => {
29                if let Some(code) = language_code {
30                    format!("External: {} (code: {})", path.display(), code)
31                } else {
32                    format!("External: {}", path.display())
33                }
34            }
35        }
36    }
37}
38
39impl Language {
40    /// Convert to string representation
41    pub fn as_str(&self) -> &'static str {
42        match self {
43            Language::English => "English",
44            Language::Japanese => "Japanese",
45        }
46    }
47
48    /// Get language code
49    pub fn code(&self) -> &'static str {
50        match self {
51            Language::English => "en",
52            Language::Japanese => "ja",
53        }
54    }
55}