Commit Graph

644 Commits

Author SHA1 Message Date
cc0f8ca813 Merge remote-tracking branch 'origin/master' into fix-1063 2020-12-28 21:57:38 +01:00
9c16571347 bat --list-languages: remove unnecessary format!() call
To trigger/verify the changed code, run

    bat --list-languages   # or -L

This is the last clippy warning in the code that you get if you run

    cargo clippy --all-targets --all-features -- --allow clippy::style

so by fixing it it becomes easier to spot when a new warning is
introduced (that does not belong to the clippy category clippy::style).
And by making it easy to spot new warnings, we increase chance of such
regressions not ending up in the code base.
2020-12-28 20:28:24 +01:00
47bb4a9c0f Introduce bat_warning! helper macro
This macro is intended to be package-internal and is not to be
considered part of the public lib API.

Use it in three places to reduce code duplication. However, main reason
for this refactoring is to allow us to fix #1063 without duplicating the
code yet another time.

The macro can also be used for the "Binary content from {} will not be
printed to the terminal" message if that message starts to use eprintln!
instead (if ever).

To trigger/verify the changed code, the following commands can be used:

    cargo run -- --theme=ansi-light tests/examples/single-line.txt
    cargo run -- --theme=does-not-exist tests/examples/single-line.txt
    cargo run -- --style=grid,rule tests/examples/single-line.txt
2020-12-28 09:27:40 +01:00
6d1c7d5f57 Fix clippy::if_same_then_else warning in --paging=auto logic 2020-12-28 09:21:27 +01:00
3099f51ba7 Add ansi theme to replace ansi-light and ansi-dark
This combines ansi-light and ansi-dark into a single theme that works
with both light and dark backgrounds. Instead of specifying white/black,
the ansi theme uses the terminal's default foreground/background color
by setting alpha=01, i.e. #00000001. This is in addition to the alpha=00
encoding where red contains an ANSI color palette number.

Now, `--theme ansi-light` and `--theme ansi-dark` will print a
deprecation notice and use ansi instead (unless the user has a custom
theme named ansi-light or ansi-dark, which would take precedence).
2020-12-21 17:05:10 +01:00
b349155f2f Remove repeated contains calls 2020-12-21 09:41:29 +01:00
bf96e6e642 make bat -L use plain style 2020-12-21 09:24:56 +01:00
cffacad306 make bat -L use pager 2020-12-21 09:24:56 +01:00
73c16574e6 Merge branch 'master' into fix-1438-newline-can-be-added-even-if-style-plain 2020-12-21 08:22:01 +01:00
68d525cd8b Don't add artificial newline to last line if --style=plain
This fixes #1438.

Note however, that using a pager such as less will add a newline itself.
So to actually not print a newline for such files, you need to either
disable paging:

  bat --style=plain --paging=never no-newline-at-end-of-file.txt

or use a "pager" that does not add a newline:

  bat --style=plain --pager=cat no-newline-at-end-of-file.txt

Note that we also update syntax tests file since a bunch of them had
missing newlines on the last lines.
2020-12-19 10:32:50 +01:00
c3fc1b88fe replace_nonprintable: Keep \n around
Since it has a functional role, we can not just replace it, we must keep
it around. This also allows us to simplify the code slightly.

We must fix this before we fix #1438 since otherwise the \n will be
missing with --style=plain, since we will stop adding it if it is
missing.
2020-12-19 10:27:06 +01:00
84b0702399 only print themes hint in interactive mode 2020-12-17 10:41:07 +01:00
986d0e9777 Ignore PAGER=most by default with a warning to stderr
closes #1063
2020-11-27 06:47:46 +01:00
f4202361b4 Add Pager helper with info about where the value comes from
In preparation of fixing issue #1063.
This is a pure refactoring with no intended functional side effects.
2020-11-27 06:42:58 +01:00
a6810e3353 Revert "Add io cycle detection with clircle"
This reverts commit aa2ae19dfd.
2020-11-24 21:40:11 +01:00
1fbdef06aa Use unreachable!(…) 2020-11-23 14:25:01 +01:00
f5531cc7fa remove all matches 2020-11-23 14:25:01 +01:00
2ccff145ed remove unuseful matches expression 2020-11-23 14:25:01 +01:00
43b2ee5e71 fix some clippy warnings 2020-11-23 14:25:01 +01:00
31793cfa62 Add io cycle detection with clircle 2020-11-23 14:06:54 +01:00
61f947a580 Merge pull request #1276 from tommilligan/style-rule
style: add component 'rule' for horizontal file delimiter
2020-10-31 23:14:00 -07:00
8e8131590c Use platform based path concatenation 2020-10-30 08:04:14 +01:00
3acfe790b9 Add extra themes help to output 2020-10-30 08:04:14 +01:00
9837948c3a Throws an error when bat is being user as pager.
As mentioned on #1334 `bat` should not be used as a value for `pager`,
this change checks both the balue of `bat` provided as a parameter or
as an environment variable.
2020-10-29 19:33:58 +01:00
3015ebfba1 disable rule when grid enabled, and print warning 2020-10-12 09:04:57 +01:00
aa4000cb0d style: add component 'rule' for horizontal file delimiter 2020-10-12 09:04:27 +01:00
b3903175c8 Auto-format Rust code 2020-10-11 21:57:12 +02:00
6615eceb18 Code review: replace if let with equals operator 2020-10-08 18:51:42 +02:00
53f5a37f01 Code review
- Replace bools with enums
- Replace short flag with long flag
2020-10-08 18:51:42 +02:00
bbef2f41ec Add -S flag to less when --wrap=never (closes #1255)
Prevent less from wrapping lines by setting the proper flag when `--wrap=never`.
If the user set a custom value for `--pager`, no additional flag is set.
2020-10-08 18:51:42 +02:00
8ff890635f add an after help NOTE 2020-10-04 06:33:11 +02:00
30993a8bfc Simplify code 2020-10-01 21:06:37 +02:00
2258fb2713 Remove .unwrap() in insert call to prevent crashes 2020-10-01 21:06:37 +02:00
a46191b8bf Remove .unwrap() to prevent crashes 2020-10-01 21:06:37 +02:00
9c4c3e965b Remove non-working unit test 2020-10-01 21:06:37 +02:00
31acbe20d3 Support XDG_CONFIG_HOME git config files 2020-10-01 21:06:37 +02:00
32d22f464d Improve --style help text, closes #1146 2020-09-20 21:00:04 +02:00
71b2089384 Code formatting 2020-09-20 20:47:21 +02:00
57aa88a13a Improve --file-name help text, closes #1109 2020-09-20 20:43:30 +02:00
f84aceec3d Fix unwrap error 2020-09-20 19:54:05 +02:00
83c7750656 Use unwrap 2020-09-20 12:14:21 +02:00
c477e23fe9 Handle file extension conflicts in --list-languages 2020-09-20 12:14:21 +02:00
31fb7087f1 Revert to previous commit 2020-09-20 12:14:21 +02:00
52d6701f8f Fix undesired behavior 2020-09-20 12:14:21 +02:00
f97634011e Handle file extension conflicts in --list-languages (#1076) 2020-09-20 12:14:21 +02:00
5df449bcf3 Remove unnecessary parenthesis 2020-09-14 11:24:14 +02:00
6017989c4c removed printlns, updated Changelog, updated man 2020-09-14 11:24:14 +02:00
d349974089 updated PR based on comments 2020-09-14 11:24:14 +02:00
ccdea6a429 remove println 2020-09-14 11:24:14 +02:00
fdf11326ef added additional alias for color=always when always-decorations flag is triggered 2020-09-14 11:24:14 +02:00