1
0
mirror of https://github.com/sharkdp/bat.git synced 2025-07-13 18:43:21 +01:00
Commit Graph

80 Commits

Author SHA1 Message Date
05e9da390f bat cache --build: Print syntect error message for themes if any
This will fix  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
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  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
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. . 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
c477e23fe9 Handle file extension conflicts in --list-languages 2020-09-20 12:14:21 +02:00
fc121f0c87 Defaults *.fs to F# 2020-06-26 21:42:05 -03:00
9cc8e52512 Fix compiler warning for 'windows' tests (dead_code) 2020-06-03 09:13:47 +02:00
0319149b4d [breaking] Remove special handling for theme previews 2020-05-29 22:13:10 +02:00
9cb43ef64d Update tests 2020-05-27 10:09:57 +02:00
bd17fd571f Switch from path-absolutize to path_abs
closes 
2020-05-26 08:11:26 +02:00
943b1f82b6 Fix syntax detection for symlinks
closes 
2020-05-24 17:32:43 +02:00
c4031ad65c Fix syntax detection for files called 'rails'
closes 
2020-05-24 11:27:42 +02:00
5aa20c090b Refactor HighlightingAssets::get_syntax to return Result type 2020-05-16 13:44:26 +02:00
cc52f79e42 Add helper fn for checking if opened input is theme preview file 2020-05-15 12:20:20 -07:00
59140b458c Consolidate syntax detection behavior for all InputKind types 2020-05-13 02:53:30 -07:00
157b8dd848 Rename test for checking if inputkinds are consistent 2020-05-13 00:47:18 -07:00
1fb669ae1a Test that OrdinaryFile consistent with CustomReader 2020-05-13 00:38:56 -07:00
7d07aa395a Change assets.rs tests to use InputKind::CustomReader
This should avoid errors in filesystems that don't
support UTF-8 or invalid UTF-8.
2020-05-13 00:38:41 -07:00
f39487fca9 Make syntax detection more consistent for Reader and File inputs 2020-05-11 19:44:09 -07:00
e37e9c1214 Fix some clippy lints
Some might actually improve perf
2020-04-24 16:11:05 +02:00
261a7ea154 Add *_with_name methods 2020-04-22 23:55:28 +02:00
53a973e9dd Add syntaxes and themes method 2020-04-22 23:55:28 +02:00
702cb198da Rename error module 2020-04-22 23:55:28 +02:00
26c951fec4 Fix warnings, sort imports, input from string 2020-04-22 23:55:28 +02:00
590960f7f5 Completely refactor 'input' module 2020-04-22 23:55:28 +02:00
f3b90ddb38 Add InputDescription 2020-04-22 23:55:28 +02:00
f8d0956893 Rename InputFile => Input 2020-04-22 23:55:28 +02:00
1dc328ad49 Separate inputs from config 2020-04-22 23:55:28 +02:00
057e4eced1 Large refactoring towards a better builder structure 2020-04-22 23:55:28 +02:00
2e9cf63a5f Fix compilation of library 2020-04-21 18:14:31 +02:00
72618db179 Add metadata information to cached assets
When saving/reading user-provided syntaxes or themes, `bat` will now maintain a
`metadata.yaml` file which includes information about the `bat` version which was
used to create the cached files. When loading cached files, we now print an error
if they have been created with an incompatible version

closes 
2020-04-21 18:14:31 +02:00
34619a2e89 Small refactoring, handle invalid UTF-8 filenames 2020-04-21 08:57:15 +02:00
83d408bab3 Extract common syntax functionality to helper fns 2020-04-21 08:57:15 +02:00
1b8ce60054 Pass stdin as a generic BufRead, fix stdin tests 2020-04-21 08:57:15 +02:00
90e7d2fe33 Rename field name, new constructors 2020-04-21 08:57:15 +02:00
04fa84aea7 Moved user_provided_filename to be contained within OrdinaryFile struct 2020-04-21 08:57:15 +02:00
a3f8140fbe Use --file-name to detect syntax highlighting
Closes 
2020-04-21 08:57:15 +02:00
eb2f3ddb7c Rename test methods 2020-03-22 11:02:51 +01:00
dfd3ef022e Add more default mappings, reverse traversal 2020-03-22 11:02:51 +01:00
57aed07814 Use absolute path for lookup in database 2020-03-22 11:02:51 +01:00
bd8a13dbc9 Initial implementation of glob-based syntax mapping 2020-03-22 11:02:51 +01:00
32346612b7 Move syntaxes, fixes 2020-03-21 23:53:53 +01:00
dfe5eb3e98 Add an even simple example 2020-03-21 22:21:23 +01:00
8c500a7e40 Hide get_syntax, move tests to module 2020-03-21 22:21:23 +01:00
acf51bd7b3 Rename methods and parameters 2020-03-21 22:21:23 +01:00
83dc13a86d Add fallback theme, remove BAT_THEME_DEFAULT 2020-03-21 22:21:23 +01:00
094c526a0e Hide some methods from HighlightingAssets 2020-03-21 22:21:23 +01:00
62f2d0c100 Do not export syntax_set and theme_set 2020-03-21 22:21:23 +01:00
7e0115641d Move error module to separate file 2020-03-21 22:21:23 +01:00
06b7be7ee9 Major restructuring of theme/syntax handling 2020-03-21 19:19:15 +01:00
2253d07341 Derive fmt::Debug whenever possible 2019-10-20 21:43:51 +02:00