mirror of
https://github.com/sharkdp/bat.git
synced 2024-11-25 09:13:39 +01:00
Print error message when invalid syntax is specified
This commit is contained in:
parent
5aa20c090b
commit
35b6067496
@ -10,6 +10,9 @@
|
|||||||
- `--map-syntax` doesn't work with names provided through `--file-name` (@eth-p)
|
- `--map-syntax` doesn't work with names provided through `--file-name` (@eth-p)
|
||||||
|
|
||||||
## Other
|
## Other
|
||||||
|
|
||||||
|
- bat now prints an error if an invalid syntax is specified (@sharkdp)
|
||||||
|
|
||||||
## New syntaxes
|
## New syntaxes
|
||||||
## New themes
|
## New themes
|
||||||
## `bat` as a library
|
## `bat` as a library
|
||||||
|
@ -121,7 +121,7 @@ impl<'b> Controller<'b> {
|
|||||||
&mut opened_input,
|
&mut opened_input,
|
||||||
#[cfg(feature = "git")]
|
#[cfg(feature = "git")]
|
||||||
&line_changes,
|
&line_changes,
|
||||||
))
|
)?)
|
||||||
};
|
};
|
||||||
|
|
||||||
let result = self.print_file(
|
let result = self.print_file(
|
||||||
|
@ -112,7 +112,7 @@ impl<'a> InteractivePrinter<'a> {
|
|||||||
assets: &'a HighlightingAssets,
|
assets: &'a HighlightingAssets,
|
||||||
input: &mut OpenedInput,
|
input: &mut OpenedInput,
|
||||||
#[cfg(feature = "git")] line_changes: &'a Option<LineChanges>,
|
#[cfg(feature = "git")] line_changes: &'a Option<LineChanges>,
|
||||||
) -> Self {
|
) -> Result<Self> {
|
||||||
let theme = assets.get_theme(&config.theme);
|
let theme = assets.get_theme(&config.theme);
|
||||||
|
|
||||||
let background_color_highlight = theme.settings.line_highlight;
|
let background_color_highlight = theme.settings.line_highlight;
|
||||||
@ -164,14 +164,18 @@ impl<'a> InteractivePrinter<'a> {
|
|||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
// Determine the type of syntax for highlighting
|
// Determine the type of syntax for highlighting
|
||||||
let syntax = assets
|
let syntax = match assets.get_syntax(config.language, input, &config.syntax_mapping) {
|
||||||
.get_syntax(config.language, input, &config.syntax_mapping)
|
Ok(syntax) => syntax,
|
||||||
.unwrap_or_else(|_| assets.syntax_set.find_syntax_plain_text());
|
Err(Error(ErrorKind::UndetectedSyntax(_), _)) => {
|
||||||
|
assets.syntax_set.find_syntax_plain_text()
|
||||||
|
}
|
||||||
|
Err(e) => return Err(e),
|
||||||
|
};
|
||||||
|
|
||||||
Some(HighlightLines::new(syntax, theme))
|
Some(HighlightLines::new(syntax, theme))
|
||||||
};
|
};
|
||||||
|
|
||||||
InteractivePrinter {
|
Ok(InteractivePrinter {
|
||||||
panel_width,
|
panel_width,
|
||||||
colors,
|
colors,
|
||||||
config,
|
config,
|
||||||
@ -183,7 +187,7 @@ impl<'a> InteractivePrinter<'a> {
|
|||||||
highlighter,
|
highlighter,
|
||||||
syntax_set: &assets.syntax_set,
|
syntax_set: &assets.syntax_set,
|
||||||
background_color_highlight,
|
background_color_highlight,
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_horizontal_line(&mut self, handle: &mut dyn Write, grid_char: char) -> Result<()> {
|
fn print_horizontal_line(&mut self, handle: &mut dyn Write, grid_char: char) -> Result<()> {
|
||||||
|
Loading…
Reference in New Issue
Block a user