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