#base-16 #color-scheme #tinted-theming #command-line-tool #cli #base24

bin+lib tinted-builder-rust

A Tinted Theming template builder which uses yaml color schemes to generate theme files

5 unstable releases

0.3.0 Apr 1, 2024
0.2.2 Mar 27, 2024
0.2.1 Mar 11, 2024
0.2.0 Mar 11, 2024
0.1.0 Mar 8, 2024

#518 in Template engine

Download history 161/week @ 2024-03-03 273/week @ 2024-03-10 24/week @ 2024-03-17 112/week @ 2024-03-24 159/week @ 2024-03-31 5/week @ 2024-04-07

309 downloads per month

MIT/Apache

42KB
604 lines

tinted-builder-rust

A builder for base16 and base24 templates using the 0.11.0 builder specification.

This crate contains a command-line tool to build base16 and base24 templates. It is also a library crate which you can use to directly build templates within your own Rust application.

Table of Contents

CLI

Installation

Cargo

cargo install tinted-builder-rust

Homebrew

brew tap tinted-theming/tinted
brew install tinted-builder-rust

Binaries

Download the relevant binary from the repository releases page.

Basic Usage

tinted-builder-rust sync # To sync with latest schemes
tinted-builder-rust build path/to/base16-template

Commands

The following is a table of the available subcommands for the CLI tool (tinted-builder-rust), including the descriptions and any notable arguments.

Subcommand Description Arguments Example Usage
sync Installs and or updates latest schemes. - tinted-builder-rust sync
build Builds the themes of a template. template_path: Path to template directory. tinted-builder-rust build ./path/to/base16-template

Flags

Flag/Option Description Applicable Subcommands Default Value Example Usage
--schemes-dir -s Path to a custom local schemes directory to use when building. Only necessary if the latest schemes repository is not desired. build tinted-builder-rust build . --schemes-dir=/path/to/schemes/dir
--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

Builder specification

tinted-builder-rust implements the 0.11.0 builder specification. This specification details the scheme yaml format or schema as well as the variables the builder should provide when rendering template mustache file. Have a look at the builder specification document for more details.

Library

This library exposes a Scheme and Template struct which you can use to generate your own themes using base16 and base24 templates and 0.11.0 compliant base16 and base24 scheme files.

Internally tinted-builder-rust uses ramhorns to render the templates.

Library installation

cargo add tinted-builder-rust

Library Usage

use tinted_builder_rust::{Scheme, Template};
use std::fs::read_to_string;

let template_str = read_to_string("path/to/template.mustache").unwrap();
let scheme_str = read_to_string("path/to/scheme.yml").unwrap();

let template = Template::new(template_str).unwrap();
let scheme: Scheme = serde_yaml::from_str(&scheme_str).unwrap();

template
    .render_to_file("path/to/rendered/template", &scheme)
    .unwrap();

The Scheme struct is as follows:

pub struct Scheme {
    pub system: String,
    pub name: String,
    pub slug: String,
    pub author: String,
    pub description: Option<String>,
    pub variant: String,
    pub palette: HashMap<String, Color>,
}

pub struct Color {
    pub hex: (String, String, String),
    pub rgb: (u8, u8, u8),
    pub dec: (f32, f32, f32),
}

Template::new The Template struct simply sets the content provided to it via Template::new.

template.render_to_file(&scheme) takes the scheme and generates the variables defined in the 0.11.0 builder specification.

Contributing

Contributions are welcome! Have a look at CONTRIBUTING.md for more information.

License

Ribboncurls is dual-licensed under the [Apache 2.0] and [MIT] licenses. For more information about the licenses of the projects used by Ribboncurls, have a look at THIRD_PARTY_LICENSES.md.

Dependencies

~8–19MB
~267K SLoC