1
0
mirror of https://github.com/sharkdp/bat.git synced 2025-09-29 00:22:26 +01:00

Credit syntax definition and theme authors with new --acknowledgements option (#1971)

The text that is printed is generated when building assets, by analyzing LICENSE
and NOTICE files that comes with syntaxes and themes.

We take this opportunity to also add a NOTICE file as defined by Apache License 2.0.
This commit is contained in:
Martin Nordholts
2021-12-11 14:00:45 +01:00
committed by GitHub
parent 63ad53817d
commit a3ea798246
12 changed files with 325 additions and 7 deletions

View File

@@ -5,10 +5,14 @@ use syntect::highlighting::ThemeSet;
use syntect::parsing::{SyntaxSet, SyntaxSetBuilder};
use crate::assets::*;
use acknowledgements::build_acknowledgements;
mod acknowledgements;
pub fn build(
source_dir: &Path,
include_integrated_assets: bool,
include_acknowledgements: bool,
target_dir: &Path,
current_version: &str,
) -> Result<()> {
@@ -18,9 +22,17 @@ pub fn build(
let syntax_set = syntax_set_builder.build();
let acknowledgements = build_acknowledgements(source_dir, include_acknowledgements)?;
print_unlinked_contexts(&syntax_set);
write_assets(&theme_set, &syntax_set, target_dir, current_version)
write_assets(
&theme_set,
&syntax_set,
&acknowledgements,
target_dir,
current_version,
)
}
fn build_theme_set(source_dir: &Path, include_integrated_assets: bool) -> Result<LazyThemeSet> {
@@ -89,6 +101,7 @@ fn print_unlinked_contexts(syntax_set: &SyntaxSet) {
fn write_assets(
theme_set: &LazyThemeSet,
syntax_set: &SyntaxSet,
acknowledgements: &Option<String>,
target_dir: &Path,
current_version: &str,
) -> Result<()> {
@@ -106,6 +119,15 @@ fn write_assets(
COMPRESS_SYNTAXES,
)?;
if let Some(acknowledgements) = acknowledgements {
asset_to_cache(
acknowledgements,
&target_dir.join("acknowledgements.bin"),
"acknowledgements",
COMPRESS_ACKNOWLEDGEMENTS,
)?;
}
print!(
"Writing metadata to folder {} ... ",
target_dir.to_string_lossy()