Commit Graph

710 Commits

Author SHA1 Message Date
de6cb75f4b Addressed PR feedback. Upped min version and used matches! macro 2021-01-09 15:21:26 +01:00
83c9cb7907 fix bug where long lines were truncated in plain mode without wrap=never not being set 2021-01-09 15:21:26 +01:00
fed30b1b36 Fix theme dir hint in --list-themes output 2021-01-08 20:10:45 +01:00
da10166625 Merge remote-tracking branch 'origin/master' into fix-1063 2021-01-07 12:58:26 +01:00
26136be903 Add --diagnostics alias 2021-01-06 22:53:51 +01:00
6a52f69b58 Update to bugreport 0.3.0 2021-01-06 22:53:51 +01:00
60406c7c2d Exhaustive list of relevant environment variables 2021-01-06 22:53:51 +01:00
dec94b4111 Add config file, compile time info and less version 2021-01-06 22:53:51 +01:00
ebb97e94a9 Add --diagnostic option to bat 2021-01-06 22:53:51 +01:00
46487b201f Merge remote-tracking branch 'origin/master' into fix-1063 2021-01-06 14:30:55 +01:00
21ae26cb17 Add cycle detection with clircle, now v0.2 2021-01-05 18:21:16 +01:00
bfa5342331 Also replace 'more' from PAGER with 'less'
But first do some quite significant refactorings to keep the code clean
and easy to understand.
2020-12-30 17:59:30 +01:00
22bdc7c20f When PAGER=most, don't print a warning to stderr, silently use less instead 2020-12-30 08:25:39 +01:00
552545fe5f Merge remote-tracking branch 'origin/master' into fix-1063 2020-12-28 22:48:52 +01:00
dcfe883f4b Simplify and polish pager.rs and related code 2020-12-28 22:39:34 +01:00
05e9da390f bat cache --build: Print syntect error message for themes if any
This will fix #614 by making it clear what is wrong by showing the
following error message:

    Failed to load one or more themes from
    '/Users/me/.config/bat/themes' (reason: 'Invalid syntax theme
    settings')

We also need to add a check if theme_dir.exists(), otherwise an absent
dir will seem like an error:

    Failed to load one or more themes from
    '/Users/me/.config/bat/themes' (reason: 'IO error for
    operation on /Users/me/.config/bat/themes: No such file or
    directory (os error 2)')

(This is the same check we already have for syntax_dir.)
2020-12-28 22:32:56 +01:00
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