on master help sign in
italics enable|disable working
commite90308e1f8272b0cb863e568facc4ab4108178ef authorNisheet Sinvhal <nisheet1.sinvhal@gmail.com> dateThu 1 Nov 2018, 22:02 (8 years ago) parentd702d67
3 files changed+10−4
src/clap_app.rs+3−1 src/printer.rs+5−2 src/terminal.rs+2−1
src/clap_app.rs+3−1
@@ -324,10 +324,12 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
324324 Arg::with_name("enable-italics")
325325 .long("enable-italics")
326326 .takes_value(true)
327+ .multiple(false)
328+ .value_name("always|*never*")
327329 .possible_values(&["always", "never"])
328330 .default_value("never")
329331 .hide_default_value(true)
330− .help("Use italics in output (always, *never)")
332+ .help("Use italics in output (always, *never*)")
331333 )
332334 .subcommand(
333335 SubCommand::with_name("cache")
src/printer.rs+5−2
@@ -305,13 +305,14 @@ impl<'a> Printer for InteractivePrinter<'a> {
305305 if self.config.output_wrap == OutputWrap::None {
306306 let true_color = self.config.true_color;
307307 let colored_output = self.config.colored_output;
308−
308+ let italics = self.config.italics;
309+
309310 for &(style, region) in regions.iter() {
310311 let text = &*self.preprocess(region, &mut cursor_total);
311312 write!(
312313 handle,
313314 "{}",
314− as_terminal_escaped(style, &*text, true_color, colored_output,)
315+ as_terminal_escaped(style, &*text, true_color, colored_output, italics,)
315316 )?;
316317 }
317318
@@ -367,6 +368,7 @@ impl<'a> Printer for InteractivePrinter<'a> {
367368 ),
368369 self.config.true_color,
369370 self.config.colored_output,
371+ self.config.italics
370372 )
371373 )?;
372374 break;
@@ -406,6 +408,7 @@ impl<'a> Printer for InteractivePrinter<'a> {
406408 ),
407409 self.config.true_color,
408410 self.config.colored_output,
411+ self.config.italics
409412 ),
410413 panel_wrap.clone().unwrap()
411414 )?;
src/terminal.rs+2−1
@@ -18,6 +18,7 @@ pub fn as_terminal_escaped(
1818 text: &str,
1919 true_color: bool,
2020 colored: bool,
21+ italics: bool,
2122) -> String {
2223 let style = if !colored {
2324 Style::default()
@@ -28,7 +29,7 @@ pub fn as_terminal_escaped(
2829 color.bold()
2930 } else if style.font_style.contains(FontStyle::UNDERLINE) {
3031 color.underline()
31− } else if style.font_style.contains(FontStyle::ITALIC) {
32+ } else if style.font_style.contains(FontStyle::ITALIC) && italics {
3233 color.italic()
3334 } else {
3435 color.normal()