Skip to content

Commit 34fa1cf

Browse files
committed
Cleanup && add path to theme list
1 parent d0b8be6 commit 34fa1cf

3 files changed

Lines changed: 21 additions & 20 deletions

File tree

src/args.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ pub fn args() -> ArgMatches {
5656
.required(false)
5757
.value_parser(clap::value_parser!(u16))
5858
.default_value("9000"),
59-
)
59+
),
6060
)
6161
.subcommand(
6262
Command::new("export")
@@ -66,7 +66,7 @@ pub fn args() -> ArgMatches {
6666
.short('i')
6767
.long("input")
6868
.value_name("INPUT")
69-
.help("Specify input file (defaults to resume.json)")
69+
.help("Specify input file")
7070
.num_args(1)
7171
.required(false)
7272
.default_value("resume.json"),
@@ -85,7 +85,7 @@ pub fn args() -> ArgMatches {
8585
Arg::new("theme")
8686
.short('t')
8787
.value_name("THEME")
88-
.help("Specify theme used by `export` or specify a path starting with .")
88+
.help("Specify theme to use (name or path)")
8989
.num_args(1)
9090
.required(false)
9191
.default_value("default"),

src/core/theme.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ pub struct ThemeConfig {
3131

3232
#[derive(Clone)]
3333
pub struct Theme {
34-
name: String,
34+
pub name: String,
3535
pub path: PathBuf,
36-
config: ThemeConfig,
36+
pub config: ThemeConfig,
3737
}
3838

3939
#[derive(Clone)]
@@ -131,11 +131,8 @@ impl ThemeManager {
131131
self.themes.get(&self.current_theme.to_ascii_lowercase())
132132
}
133133

134-
pub fn get_all_themes(&self) -> Vec<(&String, &ThemeConfig)> {
135-
self.themes
136-
.iter()
137-
.map(|(name, theme)| (name, &theme.config))
138-
.collect()
134+
pub fn get_all_themes(&self) -> &HashMap<String, Theme> {
135+
&self.themes
139136
}
140137

141138
pub fn discover_themes(&mut self) {
@@ -199,7 +196,7 @@ impl ThemeManager {
199196
Ok(mut storage) => {
200197
storage.push(temp_dir);
201198
debug!("Stored temporary directory for embedded themes");
202-
},
199+
}
203200
Err(_) => {
204201
// fallback if mutex is poisoned
205202
std::mem::forget(temp_dir);

src/main.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,19 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
4444

4545
let mut table = Table::new();
4646
table
47-
.set_header(vec!["NAME", "DESCRIPTION", "AUTHOR", "VERSION"])
48-
.set_content_arrangement(ContentArrangement::Dynamic)
49-
.load_preset(comfy_table::presets::UTF8_FULL)
50-
.apply_modifier(comfy_table::modifiers::UTF8_ROUND_CORNERS)
51-
.apply_modifier(comfy_table::modifiers::UTF8_SOLID_INNER_BORDERS);
47+
.set_header(vec!["NAME", "DESCRIPTION", "AUTHOR", "VERSION", "PATH"])
48+
.set_content_arrangement(ContentArrangement::DynamicFullWidth);
5249

53-
for (name, config) in themes {
50+
for (name, theme) in themes {
51+
let config = &theme.config;
5452
table.add_row(vec![
5553
Cell::new(name)
5654
.fg(Color::Green)
5755
.add_attribute(Attribute::Bold),
5856
Cell::new(&config.description),
5957
Cell::new(&config.author),
6058
Cell::new(&config.version).fg(Color::Cyan),
59+
Cell::new(&theme.path.to_str().unwrap_or("N/A")),
6160
]);
6261
}
6362

@@ -106,7 +105,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
106105
let theme = watch_matches.get_one::<String>("theme").unwrap();
107106
let http_port = watch_matches.get_one::<u16>("http-port").unwrap();
108107
let ws_port = watch_matches.get_one::<u16>("ws-port").unwrap();
109-
108+
110109
if let Err(e) = watch::watch_command(theme, *http_port, *ws_port) {
111110
error!("Couldn't start live view: {}", e);
112111
return Err(format!("Error starting watch: {}", e).into());
@@ -179,7 +178,8 @@ fn create_custom_theme(name: &str, base: &str) -> Result<(), Box<dyn std::error:
179178

180179
let mut theme_manager = ThemeManager::new();
181180
theme_manager.set_theme(base)?;
182-
let base_theme = theme_manager.get_current_theme()
181+
let base_theme = theme_manager
182+
.get_current_theme()
183183
.ok_or_else(|| format!("Base theme '{}' not found", base))?;
184184

185185
let base_templates_dir = base_theme.path.join("templates");
@@ -197,7 +197,11 @@ version = "0.1.0"
197197
);
198198
std::fs::write(new_theme_dir.join("config.toml"), config_content)?;
199199

200-
println!("✅ Created custom theme '{}' in {}", name, new_theme_dir.display());
200+
println!(
201+
"✅ Created custom theme '{}' in {}",
202+
name,
203+
new_theme_dir.display()
204+
);
201205
println!("You can now edit the theme files in your IDE and use it with:");
202206
println!("- ferrisume watch --theme {}", name);
203207
println!("- ferrisume export --theme {}", name);

0 commit comments

Comments
 (0)