on master help sign in
#213 : output hello world for each theme when --list-theme is flagged
commit2e3784aa30ce5a445e08b4ba73e9ca19ffa73798 authorms2300 <matt.sewall@gmail.com> dateSat 25 Aug 2018, 23:21 (8 years ago) parent1088455
2 files changed+14−4
assets/hello.rs+6 src/main.rs+8−4
assets/hello.rsnew file+6
@@ -0,0 +1,6 @@
1+
2+// Hello World
3+fn main() {
4+ println!("Hello World!");
5+}
6+
src/main.rs+8−4
@@ -34,7 +34,7 @@ use std::process;
3434
3535use ansi_term::Colour::Green;
3636
37−use app::App;
37+use app::{App, Config};
3838use assets::{clear_assets, config_dir, HighlightingAssets};
3939use controller::Controller;
4040
@@ -128,10 +128,14 @@ pub fn list_languages(assets: &HighlightingAssets, term_width: usize) {
128128 }
129129}
130130
131−pub fn list_themes(assets: &HighlightingAssets) {
131+pub fn list_themes(assets: &HighlightingAssets, config: &mut Config) {
132132 let themes = &assets.theme_set.themes;
133133 for (theme, _) in themes.iter() {
134134 println!("{}", theme);
135+ config.theme = theme.to_string();
136+ config.files = vec![Some("assets/hello.rs")];
137+ let controller = Controller::new(&config, &assets);
138+ let _res = controller.run();
135139 }
136140}
137141
@@ -146,7 +150,7 @@ fn run() -> Result<bool> {
146150 Ok(true)
147151 }
148152 _ => {
149− let config = app.config()?;
153+ let mut config = app.config()?;
150154 let assets = HighlightingAssets::new();
151155
152156 if app.matches.is_present("list-languages") {
@@ -154,7 +158,7 @@ fn run() -> Result<bool> {
154158
155159 Ok(true)
156160 } else if app.matches.is_present("list-themes") {
157− list_themes(&assets);
161+ list_themes(&assets, &mut config);
158162
159163 Ok(true)
160164 } else {