mirror of
https://github.com/sharkdp/bat.git
synced 2025-09-01 10:52:24 +01:00
Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
6a6041c72c | ||
|
0d93abde67 | ||
|
1cc39a790f | ||
|
2d93da1869 |
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -236,6 +236,3 @@
|
|||||||
[submodule "assets/syntaxes/02_Extra/Dart"]
|
[submodule "assets/syntaxes/02_Extra/Dart"]
|
||||||
path = assets/syntaxes/02_Extra/Dart
|
path = assets/syntaxes/02_Extra/Dart
|
||||||
url = https://github.com/elMuso/Dartlight.git
|
url = https://github.com/elMuso/Dartlight.git
|
||||||
[submodule "assets/syntaxes/02_Extra/SublimeJQ"]
|
|
||||||
path = assets/syntaxes/02_Extra/SublimeJQ
|
|
||||||
url = https://github.com/zogwarg/SublimeJQ.git
|
|
||||||
|
11
CHANGELOG.md
11
CHANGELOG.md
@@ -1,13 +1,12 @@
|
|||||||
# v0.20.0
|
# unreleased
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- New style component `header-filesize` to show size of the displayed file in the header. See #1988 (@mdibaiee)
|
- New style component `header-filesize` to show size of the displayed file in the header. See #1988 (@mdibaiee)
|
||||||
- Use underline for line highlighting on ANSI, see #1730 (@mdibaiee)
|
|
||||||
|
|
||||||
## Bugfixes
|
## Bugfixes
|
||||||
|
|
||||||
- Fix bash completion on bash 3.x and bash-completion 1.x. See #2066 (@joshpencheon)
|
## Other
|
||||||
|
|
||||||
## Syntaxes
|
## Syntaxes
|
||||||
|
|
||||||
@@ -15,14 +14,12 @@
|
|||||||
- Associate `_vimrc` and `_gvimrc` files with the `VimL` syntax. See #2002
|
- Associate `_vimrc` and `_gvimrc` files with the `VimL` syntax. See #2002
|
||||||
- Associate `poetry.lock` files with the `TOML` syntax. See #2049
|
- Associate `poetry.lock` files with the `TOML` syntax. See #2049
|
||||||
- Associate `.mesh`, `.task`, `.rgen`, `.rint`, `.rahit`, `.rchit`, `.rmiss`, and `.rcall` with the `GLSL` syntax. See #2050
|
- Associate `.mesh`, `.task`, `.rgen`, `.rint`, `.rahit`, `.rchit`, `.rmiss`, and `.rcall` with the `GLSL` syntax. See #2050
|
||||||
- Added support for `JQ` syntax, see #2072
|
|
||||||
- Properly associate global git config files rooted in `$XDG_CONFIG_HOME/git/` or `$HOME/.config/git/`. See #2067 (@cyqsimon)
|
## Themes
|
||||||
|
|
||||||
## `bat` as a library
|
## `bat` as a library
|
||||||
|
|
||||||
- Exposed `get_syntax_set` and `get_theme` methods on `HighlightingAssets`. See #2030 (@dandavison)
|
- Exposed `get_syntax_set` and `get_theme` methods on `HighlightingAssets`. See #2030 (@dandavison)
|
||||||
- Added `HeaderFilename` and `HeaderFilesize` to `StyleComponent` enum, and mark it `#[non_exhaustive]`. See #1988 (@mdibaiee)
|
|
||||||
|
|
||||||
|
|
||||||
# v0.19.0
|
# v0.19.0
|
||||||
|
|
||||||
|
@@ -46,25 +46,3 @@ If you really think that a particular syntax or theme should be added for all
|
|||||||
users, please read the corresponding
|
users, please read the corresponding
|
||||||
[documentation](https://github.com/sharkdp/bat/blob/master/doc/assets.md)
|
[documentation](https://github.com/sharkdp/bat/blob/master/doc/assets.md)
|
||||||
first.
|
first.
|
||||||
|
|
||||||
|
|
||||||
## Regression tests
|
|
||||||
|
|
||||||
You are strongly encouraged to add regression tests. Regression tests are great,
|
|
||||||
not least because they:
|
|
||||||
|
|
||||||
* ensure that your contribution will never completely stop working,
|
|
||||||
|
|
||||||
* makes code review easier, because it becomes very clear what the code is
|
|
||||||
supposed to do.
|
|
||||||
|
|
||||||
For functional changes, you most likely want to add a test to
|
|
||||||
[`tests/integration_tests.rs`](https://github.com/sharkdp/bat/blob/master/tests/integration_tests.rs).
|
|
||||||
Look at existing tests to know how to write a new test. In short, you will
|
|
||||||
invoke the `bat` binary with a certain set of arguments, and then assert on
|
|
||||||
stdout/stderr.
|
|
||||||
|
|
||||||
To learn how to write regression tests for theme and syntax changes, read the
|
|
||||||
[Syntax
|
|
||||||
tests](https://github.com/sharkdp/bat/blob/master/doc/assets.md#syntax-tests)
|
|
||||||
section in `assets.md`.
|
|
||||||
|
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -74,7 +74,7 @@ checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bat"
|
name = "bat"
|
||||||
version = "0.20.0"
|
version = "0.19.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ansi_colours",
|
"ansi_colours",
|
||||||
"ansi_term",
|
"ansi_term",
|
||||||
|
@@ -6,7 +6,7 @@ homepage = "https://github.com/sharkdp/bat"
|
|||||||
license = "MIT/Apache-2.0"
|
license = "MIT/Apache-2.0"
|
||||||
name = "bat"
|
name = "bat"
|
||||||
repository = "https://github.com/sharkdp/bat"
|
repository = "https://github.com/sharkdp/bat"
|
||||||
version = "0.20.0"
|
version = "0.19.0"
|
||||||
exclude = ["assets/syntaxes/*", "assets/themes/*"]
|
exclude = ["assets/syntaxes/*", "assets/themes/*"]
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
edition = '2018'
|
edition = '2018'
|
||||||
|
@@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
### Sponsors
|
### Sponsors
|
||||||
|
|
||||||
A special *thank you* goes to our biggest <a href="doc/sponsors.md">sponsors</a>:<br>
|
a special thank you goes to our biggest <a href="doc/sponsors.md">sponsors</a>:<br>
|
||||||
<a href="https://workos.com/?utm_campaign=github_repo&utm_medium=referral&utm_content=bat&utm_source=github">
|
<a href="https://workos.com/?utm_campaign=github_repo&utm_medium=referral&utm_content=bat&utm_source=github">
|
||||||
<img src="doc/sponsors/workos-logo-white-bg.svg" width="200" alt="WorkOS">
|
<img src="doc/sponsors/workos-logo-white-bg.svg" width="200" alt="WorkOS">
|
||||||
<br>
|
<br>
|
||||||
|
2
assets/completions/_bat.ps1.in
vendored
2
assets/completions/_bat.ps1.in
vendored
@@ -37,7 +37,7 @@ Register-ArgumentCompleter -Native -CommandName '{{PROJECT_EXECUTABLE}}' -Script
|
|||||||
[CompletionResult]::new('-m', 'm', [CompletionResultType]::ParameterName, 'Use the specified syntax for files matching the glob pattern (''*.cpp:C++'').')
|
[CompletionResult]::new('-m', 'm', [CompletionResultType]::ParameterName, 'Use the specified syntax for files matching the glob pattern (''*.cpp:C++'').')
|
||||||
[CompletionResult]::new('--map-syntax', 'map-syntax', [CompletionResultType]::ParameterName, 'Use the specified syntax for files matching the glob pattern (''*.cpp:C++'').')
|
[CompletionResult]::new('--map-syntax', 'map-syntax', [CompletionResultType]::ParameterName, 'Use the specified syntax for files matching the glob pattern (''*.cpp:C++'').')
|
||||||
[CompletionResult]::new('--theme', 'theme', [CompletionResultType]::ParameterName, 'Set the color theme for syntax highlighting.')
|
[CompletionResult]::new('--theme', 'theme', [CompletionResultType]::ParameterName, 'Set the color theme for syntax highlighting.')
|
||||||
[CompletionResult]::new('--style', 'style', [CompletionResultType]::ParameterName, 'Comma-separated list of style elements to display (*auto*, full, plain, changes, header, header-filename, header-filesize, grid, rule, numbers, snip).')
|
[CompletionResult]::new('--style', 'style', [CompletionResultType]::ParameterName, 'Comma-separated list of style elements to display (*auto*, full, plain, changes, header, grid, rule, numbers, snip).')
|
||||||
[CompletionResult]::new('-r', 'r', [CompletionResultType]::ParameterName, 'Only print the lines from N to M.')
|
[CompletionResult]::new('-r', 'r', [CompletionResultType]::ParameterName, 'Only print the lines from N to M.')
|
||||||
[CompletionResult]::new('--line-range', 'line-range', [CompletionResultType]::ParameterName, 'Only print the lines from N to M.')
|
[CompletionResult]::new('--line-range', 'line-range', [CompletionResultType]::ParameterName, 'Only print the lines from N to M.')
|
||||||
[CompletionResult]::new('-A', 'A', [CompletionResultType]::ParameterName, 'Show non-printable characters (space, tab, newline, ..).')
|
[CompletionResult]::new('-A', 'A', [CompletionResultType]::ParameterName, 'Show non-printable characters (space, tab, newline, ..).')
|
||||||
|
17
assets/completions/bat.bash.in
vendored
17
assets/completions/bat.bash.in
vendored
@@ -2,22 +2,9 @@
|
|||||||
|
|
||||||
# Requires https://github.com/scop/bash-completion
|
# Requires https://github.com/scop/bash-completion
|
||||||
|
|
||||||
# Macs have bash3 for which the bash-completion package doesn't include
|
|
||||||
# _init_completion. This is a minimal version of that function.
|
|
||||||
__bat_init_completion()
|
|
||||||
{
|
|
||||||
COMPREPLY=()
|
|
||||||
_get_comp_words_by_ref "$@" cur prev words cword
|
|
||||||
}
|
|
||||||
|
|
||||||
_bat() {
|
_bat() {
|
||||||
local cur prev words cword split=false
|
local cur prev words cword split
|
||||||
if declare -F _init_completion >/dev/null 2>&1; then
|
_init_completion -s || return 0
|
||||||
_init_completion -s || return 0
|
|
||||||
else
|
|
||||||
__bat_init_completion -n "=" || return 0
|
|
||||||
_split_longopt && split=true
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ ${words[1]-} == cache ]]; then
|
if [[ ${words[1]-} == cache ]]; then
|
||||||
case $prev in
|
case $prev in
|
||||||
|
2
assets/completions/bat.fish.in
vendored
2
assets/completions/bat.fish.in
vendored
@@ -56,7 +56,7 @@ complete -c {{PROJECT_EXECUTABLE}} -s P -d "Disable paging. Alias for '--paging=
|
|||||||
|
|
||||||
complete -c {{PROJECT_EXECUTABLE}} -s A -l show-all -d "Show non-printable characters like space/tab/newline" -n "not __fish_seen_subcommand_from cache"
|
complete -c {{PROJECT_EXECUTABLE}} -s A -l show-all -d "Show non-printable characters like space/tab/newline" -n "not __fish_seen_subcommand_from cache"
|
||||||
|
|
||||||
complete -c {{PROJECT_EXECUTABLE}} -l style -xka "auto full plain changes header header-filename header-filesize grid rule numbers snip" -d "Comma-separated list of style elements or presets to display with file contents" -n "not __fish_seen_subcommand_from cache"
|
complete -c {{PROJECT_EXECUTABLE}} -l style -xka "auto full plain changes header grid rule numbers snip" -d "Comma-separated list of style elements or presets to display with file contents" -n "not __fish_seen_subcommand_from cache"
|
||||||
|
|
||||||
complete -c {{PROJECT_EXECUTABLE}} -l tabs -x -d "<T> Set the tab width to T spaces (width of 0 passes tabs through directly)" -n "not __fish_seen_subcommand_from cache"
|
complete -c {{PROJECT_EXECUTABLE}} -l tabs -x -d "<T> Set the tab width to T spaces (width of 0 passes tabs through directly)" -n "not __fish_seen_subcommand_from cache"
|
||||||
|
|
||||||
|
2
assets/completions/bat.zsh.in
vendored
2
assets/completions/bat.zsh.in
vendored
@@ -75,7 +75,7 @@ _{{PROJECT_EXECUTABLE}}_main() {
|
|||||||
;;
|
;;
|
||||||
|
|
||||||
style)
|
style)
|
||||||
_values -s , 'style' auto full plain changes header header-filename header-filesize grid rule numbers snip
|
_values -s , 'style' auto full plain changes header grid rule numbers snip
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
3
assets/manual/bat.1.in
vendored
3
assets/manual/bat.1.in
vendored
@@ -146,8 +146,7 @@ Configure which elements (line numbers, file headers, grid borders, Git modifica
|
|||||||
of components to display (e.g. 'numbers,changes,grid') or a pre\-defined style ('full').
|
of components to display (e.g. 'numbers,changes,grid') or a pre\-defined style ('full').
|
||||||
To set a default style, add the '\-\-style=".."' option to the configuration file or
|
To set a default style, add the '\-\-style=".."' option to the configuration file or
|
||||||
export the BAT_STYLE environment variable (e.g.: export BAT_STYLE=".."). Possible
|
export the BAT_STYLE environment variable (e.g.: export BAT_STYLE=".."). Possible
|
||||||
values: *full*, auto, plain, changes, header, header-filename, header-filesize, grid,
|
values: *full*, auto, plain, changes, header, grid, rule, numbers, snip.
|
||||||
rule, numbers, snip.
|
|
||||||
.HP
|
.HP
|
||||||
\fB\-r\fR, \fB\-\-line\-range\fR <N:M>...
|
\fB\-r\fR, \fB\-\-line\-range\fR <N:M>...
|
||||||
.IP
|
.IP
|
||||||
|
BIN
assets/syntaxes.bin
vendored
BIN
assets/syntaxes.bin
vendored
Binary file not shown.
1
assets/syntaxes/02_Extra/SublimeJQ
vendored
1
assets/syntaxes/02_Extra/SublimeJQ
vendored
Submodule assets/syntaxes/02_Extra/SublimeJQ deleted from 687058289c
@@ -181,7 +181,7 @@ man 2 select
|
|||||||
|
|
||||||
## インストール
|
## インストール
|
||||||
|
|
||||||
[](https://repology.org/project/bat-cat/versions)
|
[](https://repology.org/project/bat/versions)
|
||||||
|
|
||||||
### On Ubuntu (`apt` を使用)
|
### On Ubuntu (`apt` を使用)
|
||||||
*... や他のDebianベースのLinuxディストリビューション*
|
*... や他のDebianベースのLinuxディストリビューション*
|
||||||
|
@@ -160,7 +160,7 @@ man 2 select
|
|||||||
|
|
||||||
## Установка
|
## Установка
|
||||||
|
|
||||||
[](https://repology.org/project/bat-cat/versions)
|
[](https://repology.org/project/bat/versions)
|
||||||
|
|
||||||
### Ubuntu (с помощью `apt`)
|
### Ubuntu (с помощью `apt`)
|
||||||
*... и другие дистрибутивы основанные на Debian.*
|
*... и другие дистрибутивы основанные на Debian.*
|
||||||
|
@@ -1,5 +1,16 @@
|
|||||||
# Release checklist
|
# Release checklist
|
||||||
|
|
||||||
|
## Dependencies
|
||||||
|
|
||||||
|
See this page for a good overview: https://deps.rs/repo/github/sharkdp/bat
|
||||||
|
|
||||||
|
- [ ] Optional: update dependencies with `cargo update`. This is also done by
|
||||||
|
dependabot, so it is not strictly necessary.
|
||||||
|
- [ ] Install [cargo-outdated](https://crates.io/crates/cargo-outdated). Check
|
||||||
|
for outdated dependencies with `cargo outdated --root-deps-only` and
|
||||||
|
decide for each of them whether we want to (manually) upgrade. This will
|
||||||
|
require changes to `Cargo.toml`.
|
||||||
|
|
||||||
## Version bump
|
## Version bump
|
||||||
|
|
||||||
- [ ] Update version in `Cargo.toml`. Run `cargo build` to update `Cargo.lock`.
|
- [ ] Update version in `Cargo.toml`. Run `cargo build` to update `Cargo.lock`.
|
||||||
@@ -13,7 +24,7 @@
|
|||||||
|
|
||||||
## Update syntaxes and themes (build assets)
|
## Update syntaxes and themes (build assets)
|
||||||
|
|
||||||
- [ ] Install the latest master version (`cargo clean && cargo install -f --path .`) and make
|
- [ ] Install the latest master version (`cargo install -f --path .`) and make
|
||||||
sure that it is available on the `PATH` (`bat --version` should show the
|
sure that it is available on the `PATH` (`bat --version` should show the
|
||||||
new version).
|
new version).
|
||||||
- [ ] Run `assets/create.sh` and check in the binary asset files.
|
- [ ] Run `assets/create.sh` and check in the binary asset files.
|
||||||
@@ -21,7 +32,7 @@
|
|||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
- [ ] Review the `-h` and `--help` texts
|
- [ ] Review the `-h` and `--help` texts
|
||||||
- [ ] Review the `man` page (`man $(fd -HIp target/release/build.*out/assets/manual/bat.1) | tee`)
|
- [ ] Review the `man` page
|
||||||
|
|
||||||
## Pre-release checks
|
## Pre-release checks
|
||||||
|
|
||||||
|
@@ -1,7 +1,5 @@
|
|||||||
## Sponsors
|
## Sponsors
|
||||||
|
|
||||||
`bat` development is sponsored by many individuals and companies. Thank you very much!
|
|
||||||
|
|
||||||
Please note, that being sponsored does not affect the individuality of the `bat`
|
Please note, that being sponsored does not affect the individuality of the `bat`
|
||||||
project or affect the maintainers' actions in any way.
|
project or affect the maintainers' actions in any way.
|
||||||
We remain impartial and continue to assess pull requests solely on merit - the
|
We remain impartial and continue to assess pull requests solely on merit - the
|
||||||
|
@@ -1 +0,0 @@
|
|||||||
# Defaults are used
|
|
@@ -463,10 +463,6 @@ impl<'a> Printer for InteractivePrinter<'a> {
|
|||||||
let highlight_this_line =
|
let highlight_this_line =
|
||||||
self.config.highlighted_lines.0.check(line_number) == RangeCheckResult::InRange;
|
self.config.highlighted_lines.0.check(line_number) == RangeCheckResult::InRange;
|
||||||
|
|
||||||
if highlight_this_line && self.config.theme == "ansi" {
|
|
||||||
self.ansi_style.update("^[4m");
|
|
||||||
}
|
|
||||||
|
|
||||||
let background_color = self
|
let background_color = self
|
||||||
.background_color_highlight
|
.background_color_highlight
|
||||||
.filter(|_| highlight_this_line);
|
.filter(|_| highlight_this_line);
|
||||||
@@ -653,11 +649,6 @@ impl<'a> Printer for InteractivePrinter<'a> {
|
|||||||
writeln!(handle)?;
|
writeln!(handle)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if highlight_this_line && self.config.theme == "ansi" {
|
|
||||||
self.ansi_style.update("^[24m");
|
|
||||||
write!(handle, "\x1B[24m")?;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -122,22 +122,8 @@ impl<'a> SyntaxMapping<'a> {
|
|||||||
.insert("*.hook", MappingTarget::MapTo("INI"))
|
.insert("*.hook", MappingTarget::MapTo("INI"))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
// Global git config files rooted in `$XDG_CONFIG_HOME/git/` or `$HOME/.config/git/`
|
if let Some(xdg_config_home) = std::env::var_os("XDG_CONFIG_HOME") {
|
||||||
// See e.g. https://git-scm.com/docs/git-config#FILES
|
let git_config_path = Path::new(&xdg_config_home).join("git");
|
||||||
if let Some(xdg_config_home) =
|
|
||||||
std::env::var_os("XDG_CONFIG_HOME").filter(|val| !val.is_empty())
|
|
||||||
{
|
|
||||||
insert_git_config_global(&mut mapping, &xdg_config_home);
|
|
||||||
}
|
|
||||||
if let Some(default_config_home) = std::env::var_os("HOME")
|
|
||||||
.filter(|val| !val.is_empty())
|
|
||||||
.map(|home| Path::new(&home).join(".config"))
|
|
||||||
{
|
|
||||||
insert_git_config_global(&mut mapping, &default_config_home);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn insert_git_config_global(mapping: &mut SyntaxMapping, config_home: impl AsRef<Path>) {
|
|
||||||
let git_config_path = config_home.as_ref().join("git");
|
|
||||||
|
|
||||||
mapping
|
mapping
|
||||||
.insert(
|
.insert(
|
||||||
|
3
tests/examples/git/.config/git/config
vendored
3
tests/examples/git/.config/git/config
vendored
@@ -1,3 +0,0 @@
|
|||||||
[user]
|
|
||||||
email = foo@bar.net
|
|
||||||
name = foobar
|
|
3
tests/examples/git/.gitconfig
vendored
3
tests/examples/git/.gitconfig
vendored
@@ -1,3 +0,0 @@
|
|||||||
[user]
|
|
||||||
email = foo@bar.net
|
|
||||||
name = foobar
|
|
@@ -1117,9 +1117,7 @@ Single Line
|
|||||||
────────────────────────────────────────────────────────────────────────────────
|
────────────────────────────────────────────────────────────────────────────────
|
||||||
",
|
",
|
||||||
)
|
)
|
||||||
.stderr(
|
.stderr("\x1b[33m[bat warning]\x1b[0m: Style 'rule' is a subset of style 'grid', 'rule' will not be visible.\n");
|
||||||
"\x1b[33m[bat warning]\x1b[0m: Style 'rule' is a subset of style 'grid', 'rule' will not be visible.\n",
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
@@ -1292,25 +1290,6 @@ fn grid_for_file_without_newline() {
|
|||||||
.stderr("");
|
.stderr("");
|
||||||
}
|
}
|
||||||
|
|
||||||
// For ANSI theme, use underscore as a highlighter
|
|
||||||
#[test]
|
|
||||||
fn ansi_highlight_underline() {
|
|
||||||
bat()
|
|
||||||
.arg("--paging=never")
|
|
||||||
.arg("--color=never")
|
|
||||||
.arg("--terminal-width=80")
|
|
||||||
.arg("--wrap=never")
|
|
||||||
.arg("--decorations=always")
|
|
||||||
.arg("--theme=ansi")
|
|
||||||
.arg("--style=plain")
|
|
||||||
.arg("--highlight-line=1")
|
|
||||||
.write_stdin("Ansi Underscore Test\nAnother Line")
|
|
||||||
.assert()
|
|
||||||
.success()
|
|
||||||
.stdout("\x1B[4mAnsi Underscore Test\n\x1B[24mAnother Line")
|
|
||||||
.stderr("");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ensure that ANSI passthrough is emitted properly for both wrapping and non-wrapping printer.
|
// Ensure that ANSI passthrough is emitted properly for both wrapping and non-wrapping printer.
|
||||||
#[test]
|
#[test]
|
||||||
fn ansi_passthrough_emit() {
|
fn ansi_passthrough_emit() {
|
||||||
@@ -1361,45 +1340,6 @@ fn ignored_suffix_arg() {
|
|||||||
.stderr("");
|
.stderr("");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn all_global_git_config_locations_syntax_mapping_work() {
|
|
||||||
let fake_home = Path::new(EXAMPLES_DIR).join("git").canonicalize().unwrap();
|
|
||||||
let expected = "\u{1b}[38;5;231m[\u{1b}[0m\u{1b}[38;5;149muser\u{1b}[0m\u{1b}[38;5;231m]\u{1b}[0m
|
|
||||||
\u{1b}[38;5;231m \u{1b}[0m\u{1b}[38;5;231memail\u{1b}[0m\u{1b}[38;5;231m \u{1b}[0m\u{1b}[38;5;203m=\u{1b}[0m\u{1b}[38;5;231m \u{1b}[0m\u{1b}[38;5;186mfoo@bar.net\u{1b}[0m
|
|
||||||
\u{1b}[38;5;231m \u{1b}[0m\u{1b}[38;5;231mname\u{1b}[0m\u{1b}[38;5;231m \u{1b}[0m\u{1b}[38;5;203m=\u{1b}[0m\u{1b}[38;5;231m \u{1b}[0m\u{1b}[38;5;186mfoobar\u{1b}[0m
|
|
||||||
";
|
|
||||||
|
|
||||||
bat()
|
|
||||||
.env("XDG_CONFIG_HOME", fake_home.join(".config").as_os_str())
|
|
||||||
.arg("-f")
|
|
||||||
.arg("-p")
|
|
||||||
.arg("git/.config/git/config")
|
|
||||||
.assert()
|
|
||||||
.success()
|
|
||||||
.stdout(expected)
|
|
||||||
.stderr("");
|
|
||||||
|
|
||||||
bat()
|
|
||||||
.env("HOME", fake_home.as_os_str())
|
|
||||||
.arg("-f")
|
|
||||||
.arg("-p")
|
|
||||||
.arg("git/.config/git/config")
|
|
||||||
.assert()
|
|
||||||
.success()
|
|
||||||
.stdout(expected)
|
|
||||||
.stderr("");
|
|
||||||
|
|
||||||
bat()
|
|
||||||
.env("HOME", fake_home.as_os_str())
|
|
||||||
.arg("-f")
|
|
||||||
.arg("-p")
|
|
||||||
.arg("git/.gitconfig")
|
|
||||||
.assert()
|
|
||||||
.success()
|
|
||||||
.stdout(expected)
|
|
||||||
.stderr("");
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn acknowledgements() {
|
fn acknowledgements() {
|
||||||
bat()
|
bat()
|
||||||
|
60
tests/syntax-tests/highlighted/JQ/sample.jq
vendored
60
tests/syntax-tests/highlighted/JQ/sample.jq
vendored
@@ -1,60 +0,0 @@
|
|||||||
[38;2;249;38;114mimport[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116m../imported-file[0m[38;2;230;219;116m"[0m[38;2;248;248;242m [0m[38;2;248;248;242m;[0m
|
|
||||||
|
|
||||||
[38;2;117;113;94m#[0m[38;2;117;113;94m With Comments ![0m
|
|
||||||
[38;2;249;38;114mdef[0m[38;2;248;248;242m [0m[38;2;166;226;46mweird[0m[38;2;248;248;242m([0m[3;38;2;253;151;31m$a[0m[38;2;248;248;242m; [0m[3;38;2;253;151;31m$b[0m[38;2;248;248;242m; [0m[3;38;2;253;151;31m$c[0m[38;2;248;248;242m)[0m[38;2;248;248;242m:[0m
|
|
||||||
[38;2;248;248;242m [0m[38;2;248;248;242m[ [0m[38;2;255;255;255m$a[0m[38;2;248;248;242m, [0m[38;2;255;255;255m$b[0m[38;2;248;248;242m, [0m[38;2;255;255;255m$c[0m[38;2;248;248;242m ][0m[38;2;248;248;242m | [0m[38;2;102;217;239mtranspose[0m[38;2;248;248;242m | [0m[38;2;249;38;114mreduce[0m[38;2;248;248;242m .[0m[38;2;248;248;242m[][0m[38;2;248;248;242m[][0m[38;2;248;248;242m [0m[38;2;249;38;114mas[0m[38;2;248;248;242m [0m[38;2;255;255;255m$item[0m[38;2;248;248;242m [0m[38;2;248;248;242m([0m
|
|
||||||
[38;2;248;248;242m [0m[38;2;248;248;242m[][0m[38;2;248;248;242m;[0m
|
|
||||||
[38;2;248;248;242m . + [0m[38;2;255;255;255m$item[0m[38;2;248;248;242m.property[0m
|
|
||||||
[38;2;248;248;242m )[0m
|
|
||||||
[38;2;248;248;242m;[0m
|
|
||||||
|
|
||||||
[38;2;248;248;242m. | weird [0m[38;2;248;248;242m(.a; .b; .c)[0m[38;2;248;248;242m |[0m
|
|
||||||
|
|
||||||
[38;2;248;248;242m([0m
|
|
||||||
|
|
||||||
[38;2;249;38;114mif[0m[38;2;248;248;242m [0m[38;2;248;248;242m(. | [0m[38;2;102;217;239mcontains[0m[38;2;248;248;242m([0m[38;2;230;219;116m"[0m[38;2;230;219;116mnever[0m[38;2;230;219;116m"[0m[38;2;248;248;242m)[0m[38;2;248;248;242m )[0m[38;2;248;248;242m [0m[38;2;249;38;114mthen[0m
|
|
||||||
[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mWhy yes[0m[38;2;230;219;116m"[0m
|
|
||||||
[38;2;249;38;114melse[0m
|
|
||||||
[38;2;248;248;242m [0m[38;2;190;132;255m12.23[0m
|
|
||||||
[38;2;249;38;114mend[0m
|
|
||||||
|
|
||||||
[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114mas[0m[38;2;248;248;242m [0m[38;2;255;255;255m$never[0m[38;2;248;248;242m |[0m
|
|
||||||
|
|
||||||
[38;2;248;248;242m{[0m
|
|
||||||
[38;2;248;248;242m [0m[38;2;166;226;46mhello[0m[38;2;248;248;242m,[0m
|
|
||||||
[38;2;248;248;242m [0m[38;2;166;226;46mwhy[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mbecause[0m[38;2;230;219;116m"[0m[38;2;248;248;242m,[0m
|
|
||||||
[38;2;248;248;242m [0m[38;2;166;226;46mhello[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[38;2;248;248;242m( weird | [0m[38;2;102;217;239mascii_upcase[0m[38;2;248;248;242m )[0m[38;2;248;248;242m,[0m
|
|
||||||
[38;2;248;248;242m [0m[38;2;166;226;46mformat_eg[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[38;2;248;248;242m( . | [0m[38;2;190;132;255m@json[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mMy json string [0m[38;2;190;132;255m\([0m[38;2;248;248;242m . | this | part | just | white | ascii_upcase | transpose[0m[38;2;190;132;255m)[0m[38;2;230;219;116m"[0m[38;2;248;248;242m )[0m[38;2;248;248;242m,[0m
|
|
||||||
[38;2;248;248;242m [0m[38;2;166;226;46mnever[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[38;2;255;255;255m$never[0m[38;2;248;248;242m,[0m
|
|
||||||
[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mliteral_key[0m[38;2;230;219;116m"[0m[38;2;248;248;242m:[0m[38;2;248;248;242m literal_value[0m[38;2;248;248;242m,[0m
|
|
||||||
[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mthis[0m[38;2;230;219;116m"[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[38;2;190;132;255m12.1e12[0m[38;2;248;248;242m,[0m
|
|
||||||
[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mpart[0m[38;2;230;219;116m"[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116malmost[0m[38;2;230;219;116m"[0m
|
|
||||||
[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mlike[0m[38;2;230;219;116m"[0m[38;2;248;248;242m: [0m[38;2;248;248;242m[[0m
|
|
||||||
[38;2;248;248;242m [0m[38;2;190;132;255m12[0m[38;2;248;248;242m,[0m
|
|
||||||
[38;2;248;248;242m [0m[38;2;190;132;255m2[0m
|
|
||||||
[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mjson[0m[38;2;230;219;116m"[0m
|
|
||||||
[38;2;248;248;242m [0m[38;2;248;248;242m{[0m
|
|
||||||
[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mquite[0m[38;2;230;219;116m"[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m
|
|
||||||
[38;2;248;248;242m [0m[38;2;166;226;46msimilar[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mbut not quite[0m[38;2;230;219;116m"[0m
|
|
||||||
[38;2;248;248;242m [0m[38;2;248;248;242m}[0m
|
|
||||||
[38;2;248;248;242m [0m[38;2;248;248;242m}[0m
|
|
||||||
[38;2;248;248;242m ][0m[38;2;248;248;242m,[0m
|
|
||||||
[38;2;248;248;242m}[0m[38;2;248;248;242m | [0m[38;2;248;248;242m([0m
|
|
||||||
[38;2;248;248;242m [0m
|
|
||||||
[38;2;248;248;242m [0m[38;2;117;113;94m#[0m[38;2;117;113;94m And with very basic brace matching[0m
|
|
||||||
[38;2;248;248;242m [0m
|
|
||||||
[38;2;248;248;242m [0m[38;2;117;113;94m#[0m[38;2;117;113;94m Invalid End[0m
|
|
||||||
[38;2;248;248;242m [0m[38;2;248;248;240m][0m[38;2;248;248;242m [0m
|
|
||||||
[38;2;248;248;242m [0m
|
|
||||||
[38;2;248;248;242m [0m[38;2;117;113;94m#[0m[38;2;117;113;94m Other invalid ends[0m
|
|
||||||
[38;2;248;248;242m [0m[38;2;248;248;242m( [0m[38;2;248;248;242m[ [0m[38;2;248;248;240m}[0m[38;2;248;248;242m [0m[38;2;248;248;240m][0m[38;2;248;248;242m )[0m
|
|
||||||
|
|
||||||
[38;2;248;248;242m [0m[38;2;117;113;94m#[0m[38;2;117;113;94m A "valid" sequence[0m
|
|
||||||
[38;2;248;248;242m [0m[38;2;248;248;242m( [0m[38;2;248;248;242m[ [0m[38;2;248;248;242m{ [0m[38;2;166;226;46mkey[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[38;2;248;248;242m()[0m[38;2;248;248;242m [0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;166;226;46mother_key[0m[38;2;248;248;242m:[0m[38;2;248;248;242m( [0m[38;2;248;248;242m[ [0m[38;2;248;248;242m[][0m[38;2;248;248;242m [0m[38;2;248;248;242m[[0m[38;2;248;248;242m[][0m[38;2;248;248;242m][0m[38;2;248;248;242m ][0m[38;2;248;248;242m )[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;166;226;46mgaga[0m[38;2;248;248;242m }[0m[38;2;248;248;242m ][0m[38;2;248;248;242m )[0m
|
|
||||||
|
|
||||||
[38;2;248;248;242m [0m[38;2;117;113;94m#[0m[38;2;117;113;94m A "invalid" sequence[0m
|
|
||||||
[38;2;248;248;242m [0m[38;2;248;248;242m( [0m[38;2;248;248;242m[ [0m[38;2;248;248;242m{ [0m[38;2;166;226;46mkey[0m[38;2;248;248;242m:[0m[38;2;248;248;242m [0m[38;2;248;248;242m()[0m[38;2;248;248;242m [0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;166;226;46mother_key[0m[38;2;248;248;242m:[0m[38;2;248;248;242m( [0m[38;2;248;248;242m[ [0m[38;2;248;248;242m[][0m[38;2;248;248;242m [0m[38;2;248;248;242m[[0m[38;2;248;248;242m[][0m[38;2;248;248;242m ][0m[38;2;248;248;242m [0m[38;2;248;248;240m)[0m[38;2;248;248;242m, gaga [0m[38;2;248;248;240m}[0m[38;2;248;248;242m ] )[0m
|
|
||||||
|
|
||||||
[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mA string[0m[38;2;190;132;255m\[0m[38;2;190;132;255mn[0m[38;2;230;219;116m whith escaped characters [0m[38;2;190;132;255m\[0m[38;2;190;132;255m"[0m[38;2;230;219;116m because we can[0m[38;2;230;219;116m"[0m
|
|
||||||
[38;2;248;248;242m)[0m
|
|
||||||
|
|
25
tests/syntax-tests/source/JQ/LICENSE.md
vendored
25
tests/syntax-tests/source/JQ/LICENSE.md
vendored
@@ -1,25 +0,0 @@
|
|||||||
The `sample.jq` file was taken from [SublimeJQ] under the following license:
|
|
||||||
|
|
||||||
[SublimeJQ]: https://github.com/zogwarg/SublimeJQ
|
|
||||||
|
|
||||||
MIT License
|
|
||||||
|
|
||||||
Copyright (c) 2017 Thomas Buick
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
60
tests/syntax-tests/source/JQ/sample.jq
vendored
60
tests/syntax-tests/source/JQ/sample.jq
vendored
@@ -1,60 +0,0 @@
|
|||||||
import "../imported-file" ;
|
|
||||||
|
|
||||||
# With Comments !
|
|
||||||
def weird($a; $b; $c):
|
|
||||||
[ $a, $b, $c ] | transpose | reduce .[][] as $item (
|
|
||||||
[];
|
|
||||||
. + $item.property
|
|
||||||
)
|
|
||||||
;
|
|
||||||
|
|
||||||
. | weird (.a; .b; .c) |
|
|
||||||
|
|
||||||
(
|
|
||||||
|
|
||||||
if (. | contains("never") ) then
|
|
||||||
"Why yes"
|
|
||||||
else
|
|
||||||
12.23
|
|
||||||
end
|
|
||||||
|
|
||||||
) as $never |
|
|
||||||
|
|
||||||
{
|
|
||||||
hello,
|
|
||||||
why: "because",
|
|
||||||
hello: ( weird | ascii_upcase ),
|
|
||||||
format_eg: ( . | @json "My json string \( . | this | part | just | white | ascii_upcase | transpose)" ),
|
|
||||||
never: $never,
|
|
||||||
"literal_key": literal_value,
|
|
||||||
"this": 12.1e12,
|
|
||||||
"part": "almost"
|
|
||||||
"like": [
|
|
||||||
12,
|
|
||||||
2
|
|
||||||
"json"
|
|
||||||
{
|
|
||||||
"quite": {
|
|
||||||
similar: "but not quite"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
} | (
|
|
||||||
|
|
||||||
# And with very basic brace matching
|
|
||||||
|
|
||||||
# Invalid End
|
|
||||||
]
|
|
||||||
|
|
||||||
# Other invalid ends
|
|
||||||
( [ } ] )
|
|
||||||
|
|
||||||
# A "valid" sequence
|
|
||||||
( [ { key: () , other_key:( [ [] [[]] ] ), gaga } ] )
|
|
||||||
|
|
||||||
# A "invalid" sequence
|
|
||||||
( [ { key: () , other_key:( [ [] [[] ] ), gaga } ] )
|
|
||||||
|
|
||||||
"A string\n whith escaped characters \" because we can"
|
|
||||||
)
|
|
||||||
|
|
Reference in New Issue
Block a user