Repository: sharkdp/bat
File: src/printer.rs (Rust)

Code before:
            // Only pad space between files, if we haven't already drawn a horizontal rule
            if add_header_padding && !self.config.style_components.rule() {
                writeln!(handle)?;
            }
        }

        header_components.iter().try_for_each(|component| {
            self.print_header_component_indent(handle)?;

            match component {
                StyleComponent::HeaderFilename => writeln!(
                    handle,
                    "{}{}{}",
                    description
                        .kind()
                        .map(|kind| format!("{}: ", kind))
                        .unwrap_or_else(|| "".into()),
                    self.colors.header_value.paint(description.title()),
                    mode
                ),

                StyleComponent::HeaderFilesize => {
                    let bsize = metadata
                        .size
                        .map(|s| format!("{}", ByteSize(s)))
                        .unwrap_or("".into());
                    writeln!(handle, "Size: {}", self.colors.header_value.paint(bsize))
                }
                _ => Ok(()),
            }
        })?;

        if self.config.style_components.grid() {
            if self.content_type.map_or(false, |c| c.is_text()) || self.config.show_nonprintable {
                self.print_horizontal_line(handle, '┼')?;
            } else {
                self.print_horizontal_line(handle, '┴')?;
            }
        }

        Ok(())
    }

    fn print_footer(&mut self, handle: &mut dyn Write, _input: &OpenedInput) -> Result<()> {
        if self.config.style_components.grid()
            && (self.content_type.map_or(false, |c| c.is_text()) || self.config.show_nonprintable)
        {
            self.print_horizontal_line(handle, '┴')
        } else {
            Ok(())
        }

Review comment (suggestion):
It's quite possible that `metadata.size` is empty, right? For example, if the input comes from STDIN. I think we should also add a test case for this. Maybe we want to skip the `Size: ` line completely in this case? Or at least print something like `Size: -`.

Code after:
            // Only pad space between files, if we haven't already drawn a horizontal rule
            if add_header_padding && !self.config.style_components.rule() {
                writeln!(handle)?;
            }
        }

        header_components.iter().try_for_each(|component| {
            self.print_header_component_indent(handle)?;

            match component {
                StyleComponent::HeaderFilename => writeln!(
                    handle,
                    "{}{}{}",
                    description
                        .kind()
                        .map(|kind| format!("{}: ", kind))
                        .unwrap_or_else(|| "".into()),
                    self.colors.header_value.paint(description.title()),
                    mode
                ),

                StyleComponent::HeaderFilesize => {
                    let bsize = metadata
                        .size
                        .map(|s| format!("{}", ByteSize(s)))
                        .unwrap_or_else(|| "-".into());
                    writeln!(handle, "Size: {}", self.colors.header_value.paint(bsize))
                }
                _ => Ok(()),
            }
        })?;

        if self.config.style_components.grid() {
            if self.content_type.map_or(false, |c| c.is_text()) || self.config.show_nonprintable {
                self.print_horizontal_line(handle, '┼')?;
            } else {
                self.print_horizontal_line(handle, '┴')?;
            }
        }

        Ok(())
    }

    fn print_footer(&mut self, handle: &mut dyn Write, _input: &OpenedInput) -> Result<()> {
        if self.config.style_components.grid()
            && (self.content_type.map_or(false, |c| c.is_text()) || self.config.show_nonprintable)
        {
            self.print_horizontal_line(handle, '┴')
        } else {
            Ok(())
        }