@@ -19,6 +19,7 @@ use errors::*;
1919use inputfile::InputFile;
2020use line_range::LineRange;
2121use style::{OutputComponent, OutputComponents, OutputWrap};
22+use syntax_mapping::SyntaxMapping;
2223use util::transpose;
2324
2425#[derive(Debug, Clone, Copy, PartialEq)]
@@ -66,6 +67,9 @@ pub struct Config<'a> {
6667
6768 /// The syntax highlighting theme
6869 pub theme: String,
70+
71+ /// File extension/name mappings
72+ pub syntax_mapping: SyntaxMapping,
6973}
7074
7175fn is_truecolor_terminal() -> bool {
@@ -146,6 +150,20 @@ impl App {
146150 }
147151 };
148152
153+ let mut syntax_mapping = SyntaxMapping::new();
154+
155+ if let Some(values) = self.matches.values_of("map-syntax") {
156+ for from_to in values {
157+ let parts: Vec<_> = from_to.split(":").collect();
158+
159+ if parts.len() != 2 {
160+ return Err("Invalid syntax mapping. The format of the -m/--map-syntax option is 'from:to'.".into());
161+ }
162+
163+ syntax_mapping.insert(parts[0].into(), parts[1].into());
164+ }
165+ }
166+
149167 Ok(Config {
150168 true_color: is_truecolor_terminal(),
151169 language: self.matches.value_of("language"),
@@ -202,6 +220,7 @@ impl App {
202220 .unwrap_or(String::from(BAT_THEME_DEFAULT)),
203221 line_range: transpose(self.matches.value_of("line-range").map(LineRange::from))?,
204222 output_components,
223+ syntax_mapping,
205224 })
206225 }
207226