Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@
### Added

- Expose a `slug-underscored` variable, matching `scheme-slug-underscored`
- Add `build --prune` flag which deletes previously generated themes, or
unknown files in out directory, of files that aren't recognised. Renaming a
scheme previously left the old theme behind in every template repository
indefinitely. Pruning is limited to files matching a template config entry's
own `filename` pattern, skips scheme systems that generated nothing in the same
run, and only runs once every config entry has been generated successfully.

### Changed

- **Breaking (library):** `operation_build::build()` takes a new `prune`
argument before `is_quiet`.

## [0.21.0] - 2026-06-15

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,15 @@ The following is a table of the available subcommands for the CLI tool (tinted-b
| Subcommand | Description | Arguments | Example Usage | Flags |
|------------|--------------------------------------|----------------------|--------------------------------------------|-------|
| `sync` | Installs and or updates latest schemes. | - | `tinted-builder-rust sync` | `--quiet` (silence stderr and stdout) |
| `build` | Builds the themes of a template. | `template_path`: Path to template directory. | `tinted-builder-rust build ./path/to/base16-template` | `--quiet` (silence stderr and stdout), `--sync` (equivalent of running `tinted-builder-rust sync` before `tinted-builder-rust build`) |
| `build` | Builds the themes of a template. | `template_path`: Path to template directory. | `tinted-builder-rust build ./path/to/base16-template` | `--quiet` (silence stderr and stdout), `--sync` (equivalent of running `tinted-builder-rust sync` before `tinted-builder-rust build`), `--prune` (remove themes whose scheme no longer exists) |

## Flags

| Flag/Option | Description | Applicable Subcommands | Default Value | Example Usage |
|-------------------|-----------------------------------------|------------------------|---------------|-------------------------------------------|
| `--schemes-dir` `-s` | Path to local schemes directories. Used by `build` to find schemes and by `sync` to clone/pull into those paths. | `build`, `sync` | Defaults to `<data-dir>/schemes` | `tinted-builder-rust build . -s /path/one -s /path/two` |
| `--ignore` `-i` | One or more glob patterns to skip when scanning schemes. Repeat this flag to add multiple ignores. | `build` | - | `tinted-builder-rust build . --ignore "**/LICENSE"` |
| `--prune` | Delete previously generated themes whose scheme no longer exists, such as the files left behind when a scheme is renamed. Only files matching a template config entry's own `filename` pattern are removed, and only for scheme systems that produced at least one theme in the same run. | `build` | Disabled | `tinted-builder-rust build . --prune` |
| `--data-dir` `-d` | Specifies a custom path for the data directory. | All | Linux: `$XDG_DATA_HOME/tinted-theming/tinted-builder-rust` or `~/.local/share`. MacOS: `~/Library/Application\ Support/tinted-theming/tinted-builder-rust` | `tinted-builder-rust sync --data-dir /path/to/custom/data-dir` |
| `--help` `-h` | Displays help information for the subcommand. | All | - | `tinted-builder-rust --help`, `tinted-builder-rust build --help`, etc |
| `--version` `-V` | Shows the version of tinted-builder-rust. | All | - | `tinted-builder-rust --version` |
Expand Down
2 changes: 0 additions & 2 deletions tinted-builder-rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ license = "GPL-3.0-only"
description = "Simple Base16, Base24 and Tinted8 compliant rendering of mustache templates"
keywords = ["base16", "tinted8", "mustache", "template"]
categories = ["template-engine"]
homepage = "https://github.com/tinted-theming/tinted-builder-rust"
repository = "https://github.com/tinted-theming/tinted-builder-rust"
documentation = "https://github.com/tinted-theming/tinted-builder-rust"
readme = "README.md"
rust-version.workspace = true

[dependencies]
Expand Down
33 changes: 32 additions & 1 deletion tinted-builder-rust/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ build templates within your own Rust application.
- [Basic usage](#basic-usage)
- [Commands](#commands)
- [Flags](#flags)
- [Pruning themes](#pruning-themes)
- [Builder specification](#builder-specification)
- [Contributing](#contributing)
- [License](#license)
Expand Down Expand Up @@ -54,18 +55,48 @@ The following is a table of the available subcommands for the CLI tool (tinted-b
| Subcommand | Description | Arguments | Example Usage | Flags |
|------------|-------------|-----------|---------------|-------|
| `sync` | Installs and or updates latest schemes. | - | `tinted-builder-rust sync` | `--quiet` (silence stderr and stdout) |
| `build` | Builds the themes of a template. | `template_path`: Path to template directory. | `tinted-builder-rust build ./path/to/base16-template` | `--quiet` (silence stderr and stdout), `--sync` (equivalent of running `tinted-builder-rust sync` before `tinted-builder-rust build`) |
| `build` | Builds the themes of a template. | `template_path`: Path to template directory. | `tinted-builder-rust build ./path/to/base16-template` | `--quiet` (silence stderr and stdout), `--sync` (equivalent of running `tinted-builder-rust sync` before `tinted-builder-rust build`), `--prune` (remove themes whose scheme no longer exists) |

## Flags

| Flag/Option | Description | Applicable Subcommands | Default Value | Example Usage |
|-------------|-------------|------------------------|---------------|---------------|
| `--schemes-dir` `-s` | Path to local schemes directories. Used by `build` to find schemes and by `sync` to clone/pull into those paths. | `build`, `sync` | Defaults to `<data-dir>/schemes` | `tinted-builder-rust build . -s /path/one -s /path/two` |
| `--ignore` `-i` | One or more glob patterns to skip when scanning schemes. Repeat this flag to add multiple ignores. | `build` | - | `tinted-builder-rust build . --ignore "**/LICENSE"` |
| `--prune` | Delete previously generated themes whose scheme no longer exists, such as the files left behind when a scheme is renamed. See [Pruning themes](#pruning-themes). | `build` | Disabled | `tinted-builder-rust build . --prune` |
| `--data-dir` `-d` | Specifies a custom path for the data directory. | All | Linux: `$XDG_DATA_HOME/tinted-theming/tinted-builder-rust`. macOS: `~/Library/Application\ Support/tinted-theming/tinted-builder-rust` | `tinted-builder-rust sync --data-dir /path/to/custom/data-dir` |
| `--help` `-h` | Displays help information for the subcommand. | All | - | `tinted-builder-rust --help`, `tinted-builder-rust build --help`, etc |
| `--version` `-V` | Shows the version of tinted-builder-rust. | All | - | `tinted-builder-rust --version` |

## Pruning theme files

A build only ever writes files, so a theme generated for a scheme that has
since been renamed or deleted stays in the template repository forever.
Passing `--prune` removes those leftovers once the build has finished:

```sh
tinted-builder-rust build . --prune
```

Pruning is deliberately conservative. A file is only removed when all of the
following hold:

- It sits directly in the output directory of a `templates/config.yaml` entry,
and its name matches that entry's `filename` pattern with the scheme slug
substituted. For `colors/{{ scheme-system }}-{{ scheme-slug }}.conf`, that
means only `colors/base16-*.conf` is ever considered.
- It was not written by the current build.
- Its scheme system produced at least one theme in the current build, so a
partially synced or heavily ignored schemes directory cannot wipe out an
entire system's themes.
- It is not a dotfile and not a directory.

Entries whose `filename` has no scheme slug in its last path component, such
as `list` templates, are skipped and reported as `W002`.

Note that schemes excluded with `--ignore` count as non-existent, so their
previously generated themes are pruned too.

## List usage

`tinted-builder-rust` supports an `options.list` config property which enables
Expand Down
6 changes: 6 additions & 0 deletions tinted-builder-rust/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ fn build_cli() -> Command {
.long("sync")
.help("Sync with latest schemes before build")
.action(ArgAction::SetTrue),
)
.arg(
Arg::new("prune")
.long("prune")
.help("Delete previously generated themes whose scheme no longer exists")
.action(ArgAction::SetTrue),
),
)
.subcommand(
Expand Down
5 changes: 4 additions & 1 deletion tinted-builder-rust/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ fn main() -> Result<()> {
let is_quiet = sub_matches
.get_one::<bool>("quiet")
.is_some_and(ToOwned::to_owned);
let prune = sub_matches
.get_one::<bool>("prune")
.is_some_and(ToOwned::to_owned);
let template_dir = sub_matches
.get_one::<String>("template-dir")
.cloned()
Expand All @@ -76,7 +79,7 @@ fn main() -> Result<()> {
operations::sync::sync(&data_schemes_path, is_quiet)?;
}

operations::build::build(&template_path, &schemes_path, &ignores, is_quiet)?;
operations::build::build(&template_path, &schemes_path, &ignores, prune, is_quiet)?;
}
Some(("sync", sub_matches)) => {
let is_quiet: bool = sub_matches
Expand Down
Loading
Loading