mirror of
https://github.com/sharkdp/bat.git
synced 2026-02-08 00:32:08 +00:00
feat: add paging to '-h' and '--help' (#3478)
* feat: add paging to '-h' and '--help' Fixes #1587
This commit is contained in:
@@ -605,6 +605,44 @@ fn test_help(arg: &str, expect_file: &str) {
|
||||
.assert_eq(&String::from_utf8_lossy(&assert.get_output().stdout));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn short_help_with_highlighting() {
|
||||
bat()
|
||||
.arg("-h")
|
||||
.arg("--paging=never")
|
||||
.arg("--color=always")
|
||||
.assert()
|
||||
.success()
|
||||
.stdout(predicate::str::contains("\x1B["))
|
||||
.stdout(predicate::str::contains("Usage:"))
|
||||
.stdout(predicate::str::contains("Options:"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn long_help_with_highlighting() {
|
||||
bat()
|
||||
.arg("--help")
|
||||
.arg("--paging=never")
|
||||
.arg("--color=always")
|
||||
.assert()
|
||||
.success()
|
||||
.stdout(predicate::str::contains("\x1B["))
|
||||
.stdout(predicate::str::contains("Usage:"))
|
||||
.stdout(predicate::str::contains("Options:"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn help_with_color_never() {
|
||||
bat()
|
||||
.arg("--help")
|
||||
.arg("--color=never")
|
||||
.arg("--paging=never")
|
||||
.assert()
|
||||
.success()
|
||||
.stdout(predicate::str::contains("\x1B[").not())
|
||||
.stdout(predicate::str::contains("Usage:"));
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
fn setup_temp_file(content: &[u8]) -> io::Result<(PathBuf, tempfile::TempDir)> {
|
||||
let dir = tempfile::tempdir().expect("Couldn't create tempdir");
|
||||
|
||||
Reference in New Issue
Block a user