Bevy Code Generator
A cli tool and library to scaffold boilerplate for your bevy project
This crate is currently being worked on. This crate is an extension of the cargo-color-gen CLI tool.
Get Started
install via cargo install bevygen
Then, with a tailwind scheme and output file:
bevygen color -i examples/example.json -o example_output/coloors_output.rs
Usage (v0.1.0)
See the color generation docs for details
Input Schema
A schema that looks something like this.
Additionally, it can be a JS object and this cli will attempt to reformat it as a JSON.
You can specify a JSON file with the -i parameter, or paste your json as a single line.
Pretty-printed JSONs through -stdin will fail. This may need some work.
How to generate an input schema
This CLI was built with the intention of supporting the - Tailwind Export of coolors.co.
This is a good starting point for working with your palettes!
If there is a need for quickly switching between palettes (as opposed to the current constant colors generated), please let me know!
Output
The above input will generate the following:
/// Generated using `color-gen` v0.2
use Color;
///Original hex: #462001
pub const SANDY_BROWN_100: Color = srgb;
///Original hex: #fdbc87
pub const SANDY_BROWN_600: Color = srgb;
///Original hex: #feeee1
pub const SANDY_BROWN_900: Color = srgb;
///Original hex: #e3b1af
pub const REDWOOD_800: Color = srgb;
///Original hex: #f1d8d7
pub const REDWOOD_900: Color = srgb;
///Original hex: #d58a8792
pub const REDWOOD_700: Color = srgba;
/**Error parsing hex #GGGGGG
r: Err(ParseIntError { kind: InvalidDigit })
g: Err(ParseIntError { kind: InvalidDigit })
b: Err(ParseIntError { kind: InvalidDigit })*/
pub const REDWOOD_NO_WORK: = ;
If you specify an output -o, the output will save to that file. Otherwise, it will be printed to stdout.
Help/Suggestions wanted!
I would love to know about bevy code that you think requires a lot of boilerplate. Please let me know what you find.
Ideas/suggestions for bevygen color
- it could be nice to make strongly typed palettes with enumerations
- Other schema types
- correct parsing of JS Objects (most scheme generators return this, not JSON). Currently, I use regex to reformat JSObjects, but this is faulty, and the error message is pretty poor.