Merge branch 'master' of github.com:sharkdp/bat into string-input

This commit is contained in:
Ethan P 2020-05-15 13:22:24 -07:00
commit b8687bc969
No known key found for this signature in database
GPG Key ID: 6963FD04F6CF35EA
19 changed files with 68 additions and 20 deletions

View File

@ -1,7 +1,13 @@
# unreleased
## Features
- Add padding above headers when not using a grid, see #968 and #981 (@pt2121)
## Bugfixes
- bat mishighlights Users that start with digits in SSH config, see #984
## Other
## New syntaxes
## New themes

2
Cargo.lock generated
View File

@ -114,7 +114,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "bat"
version = "0.15.0"
version = "0.15.1"
dependencies = [
"ansi_colours 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"ansi_term 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)",

View File

@ -7,7 +7,7 @@ license = "MIT/Apache-2.0"
name = "bat"
readme = "README.md"
repository = "https://github.com/sharkdp/bat"
version = "0.15.0"
version = "0.15.1"
exclude = [
"assets/syntaxes/*",
"assets/themes/*",

View File

@ -168,7 +168,7 @@ The [`prettybat`](https://github.com/eth-p/bat-extras/blob/master/doc/prettybat.
[![Packaging status](https://repology.org/badge/vertical-allrepos/bat.svg)](https://repology.org/project/bat/versions)
### On Ubuntu
### On Ubuntu (using `apt`)
*... and other Debian-based Linux distributions.*
`bat` is making its way through the [Ubuntu](https://packages.ubuntu.com/eoan/bat) and
@ -182,12 +182,22 @@ If your Ubuntu/Debian installation is new enough you can simply run:
apt install bat
```
If you install `bat` this way, please note that the executable may be installed as `batcat` instead of `bat` (due to [a name
clash with another package](https://github.com/sharkdp/bat/issues/982)). You can set up a `bat -> batcat` symlink or alias to prevent any issues that may come up because of this and to be consistent with other distrutions:
``` bash
mkdir -p ~/.local/bin
ln -s /usr/bin/batcat ~/.local/bin/bat
```
### On Ubuntu (using most recent `.deb` packages)
*... and other Debian-based Linux distributions.*
If the package has not yet been promoted to your Ubuntu/Debian installation, or you want
the most recent release of `bat`, download the latest `.deb` package from the
[release page](https://github.com/sharkdp/bat/releases) and install it via:
```bash
sudo dpkg -i bat_0.15.0_amd64.deb # adapt version number and architecture
sudo dpkg -i bat_0.15.1_amd64.deb # adapt version number and architecture
```
### On Alpine Linux

BIN
assets/syntaxes.bin vendored

Binary file not shown.

@ -1 +1 @@
Subproject commit 89b3bada3262bc58e0a5393d12a82f725d5063ad
Subproject commit 1f010d5f63f20aa8eafa57aaaeafe736e0748dca

@ -1 +1 @@
Subproject commit dfbb8bdc9a8403092c884d3eb893a270538cfa72
Subproject commit e266d279c8074aa342f106554cfa87ebe839a782

@ -1 +1 @@
Subproject commit fc034fb85ae8a277627f1148769924dbc115dbe4
Subproject commit ee3e68fce26cb7ab6ad8c8bf7ca45cfe2a70c07a

@ -1 +1 @@
Subproject commit 0ca4cc29907e9476cb603fed00d1d5fd9dc13c9c
Subproject commit 6c0d770fc74e6bc037c70cae1f94fe113b60fd95

@ -1 +1 @@
Subproject commit 16e19d5da48a7c4d30fdded8ac4c97ff643f5d7b
Subproject commit 3ec06d0e9c2d20e7bb31f0149364d25f77503d97

BIN
assets/themes.bin vendored

Binary file not shown.

@ -1 +1 @@
Subproject commit 87e01090cf5fb821a234265b3138426ae84900e7
Subproject commit 3707f68ddc535723c02c65cbc97187c1aa99ad4d

@ -1 +1 @@
Subproject commit 811a634420a0cb9023bb7afd1c8968a5aaf6a753
Subproject commit 26c57ec282abcaa76e57e055f38432bd827ac34e

@ -1 +1 @@
Subproject commit fdcbffe3175c29bb78d19dcaf9b2a456482fcf1e
Subproject commit 970abdf26b399100cbb59c6b6e693c4ff877c59d

View File

@ -180,7 +180,7 @@ apt install bat
batの最新リリースを実行する場合、または Ubuntu/Debian の古いバージョンを使用している場合は、[release page](https://github.com/sharkdp/bat/releases) から最新の `.deb` パッケージをダウンロードし、
次の方法でインストールします:
```bash
sudo dpkg -i bat_0.15.0_amd64.deb # adapt version number and architecture
sudo dpkg -i bat_0.15.1_amd64.deb # adapt version number and architecture
```
### On Alpine Linux

View File

@ -170,7 +170,7 @@ apt install bat
만약 최근 릴리즈된 bat을 사용을 원하거나 buntu/Debian 예전 버전을 사용하는 경우, [릴리즈 페이지](https://github.com/sharkdp/bat/releases)에서 다음과 같이 `.deb` 패키지를 받아 설치 할 수도 있습니다:
```bash
sudo dpkg -i bat_0.15.0_amd64.deb # adapt version number and architecture
sudo dpkg -i bat_0.15.1_amd64.deb # adapt version number and architecture
```
### On Alpine Linux

View File

@ -75,7 +75,7 @@ impl<'b> Controller<'b> {
}
};
for input in inputs.into_iter() {
for (index, input) in inputs.into_iter().enumerate() {
match input.open(io::stdin().lock()) {
Err(error) => {
print_error(&error, writer);
@ -128,6 +128,7 @@ impl<'b> Controller<'b> {
&mut *printer,
writer,
&mut opened_input,
index != 0,
#[cfg(feature = "git")]
&line_changes,
);
@ -148,10 +149,11 @@ impl<'b> Controller<'b> {
printer: &mut dyn Printer,
writer: &mut dyn Write,
input: &mut OpenedInput,
add_header_padding: bool,
#[cfg(feature = "git")] line_changes: &Option<LineChanges>,
) -> Result<()> {
if !input.reader.first_line.is_empty() || self.config.style_components.header() {
printer.print_header(writer, input)?;
printer.print_header(writer, input, add_header_padding)?;
}
if !input.reader.first_line.is_empty() {

View File

@ -33,7 +33,12 @@ use crate::terminal::{as_terminal_escaped, to_ansi_color};
use crate::wrapping::WrappingMode;
pub(crate) trait Printer {
fn print_header(&mut self, handle: &mut dyn Write, input: &OpenedInput) -> Result<()>;
fn print_header(
&mut self,
handle: &mut dyn Write,
input: &OpenedInput,
add_header_padding: bool,
) -> Result<()>;
fn print_footer(&mut self, handle: &mut dyn Write, input: &OpenedInput) -> Result<()>;
fn print_snip(&mut self, handle: &mut dyn Write) -> Result<()>;
@ -56,7 +61,12 @@ impl SimplePrinter {
}
impl Printer for SimplePrinter {
fn print_header(&mut self, _handle: &mut dyn Write, _input: &OpenedInput) -> Result<()> {
fn print_header(
&mut self,
_handle: &mut dyn Write,
_input: &OpenedInput,
_add_header_padding: bool,
) -> Result<()> {
Ok(())
}
@ -219,7 +229,12 @@ impl<'a> InteractivePrinter<'a> {
}
impl<'a> Printer for InteractivePrinter<'a> {
fn print_header(&mut self, handle: &mut dyn Write, input: &OpenedInput) -> Result<()> {
fn print_header(
&mut self,
handle: &mut dyn Write,
input: &OpenedInput,
add_header_padding: bool,
) -> Result<()> {
if !self.config.style_components.header() {
if Some(ContentType::BINARY) == self.content_type && !self.config.show_nonprintable {
writeln!(
@ -248,6 +263,9 @@ impl<'a> Printer for InteractivePrinter<'a> {
.paint(if self.panel_width > 0 { "" } else { "" }),
)?;
} else {
if add_header_padding {
writeln!(handle)?;
}
write!(handle, "{}", " ".repeat(self.panel_width))?;
}

View File

@ -615,7 +615,7 @@ fn filename_multiple_ok() {
.arg("--file-name=bar")
.assert()
.success()
.stdout("File: foo\nFile: bar\n")
.stdout("File: foo\n\nFile: bar\n")
.stderr("");
}
@ -632,6 +632,18 @@ fn filename_multiple_err() {
.failure();
}
#[test]
fn header_padding() {
bat()
.arg("--decorations=always")
.arg("--style=header")
.arg("test.txt")
.arg("single-line.txt")
.assert()
.stdout("File: test.txt\nhello world\n\nFile: single-line.txt\nSingle Line\n")
.stderr("");
}
#[cfg(target_os = "linux")]
#[test]
fn file_with_invalid_utf8_filename() {