#213 : output hello world for each theme when --list-theme is flagged

This commit is contained in:
ms2300 2018-08-25 23:21:16 -06:00 committed by David Peter
parent 1088455702
commit 2e3784aa30
2 changed files with 14 additions and 4 deletions

6
assets/hello.rs Normal file
View File

@ -0,0 +1,6 @@
// Hello World
fn main() {
println!("Hello World!");
}

View File

@ -34,7 +34,7 @@ use std::process;
use ansi_term::Colour::Green;
use app::App;
use app::{App, Config};
use assets::{clear_assets, config_dir, HighlightingAssets};
use controller::Controller;
@ -128,10 +128,14 @@ pub fn list_languages(assets: &HighlightingAssets, term_width: usize) {
}
}
pub fn list_themes(assets: &HighlightingAssets) {
pub fn list_themes(assets: &HighlightingAssets, config: &mut Config) {
let themes = &assets.theme_set.themes;
for (theme, _) in themes.iter() {
println!("{}", theme);
config.theme = theme.to_string();
config.files = vec![Some("assets/hello.rs")];
let controller = Controller::new(&config, &assets);
let _res = controller.run();
}
}
@ -146,7 +150,7 @@ fn run() -> Result<bool> {
Ok(true)
}
_ => {
let config = app.config()?;
let mut config = app.config()?;
let assets = HighlightingAssets::new();
if app.matches.is_present("list-languages") {
@ -154,7 +158,7 @@ fn run() -> Result<bool> {
Ok(true)
} else if app.matches.is_present("list-themes") {
list_themes(&assets);
list_themes(&assets, &mut config);
Ok(true)
} else {