#complete #turn #file

bin+lib genify

Turn one file into a complete project

2 releases

0.0.2 Jan 2, 2025
0.0.1 Dec 1, 2024

#14 in #complete

Download history 109/week @ 2024-11-29 19/week @ 2024-12-06 10/week @ 2024-12-13 80/week @ 2024-12-27 65/week @ 2025-01-03 1/week @ 2025-01-10

146 downloads per month

MIT license

25KB
593 lines

genify

Crates.io Docs.rs CI Coverage Status

Turn one file into a complete project.

Installation

Cargo

  • Install the rust toolchain in order to have cargo installed by following this guide.
  • run
    cargo install genify --features clap
    

Get Started

CLI

Turn one file into a complete project

Usage: genify [OPTIONS] <PATH>

Arguments:
  <PATH>

Options:
  -n, --no-interaction  Do not ask any interactive question
  -h, --help            Print help
  -V, --version         Print version

example.toml

[props]
value = "value"
dir = "tmp"
val = "val"
other = "{{ val }}"
override = "1"

[[rules]]
type = "file"
path = "{{ dir }}/some.txt"  # if the file exists will be error
content = "{{ val }} {{ value }} {{ other | pascal_case }} {{ override }} - should be replaced"

[[rules]]
type = "replace"
path = "{{ dir }}/some.txt"
replace = "should.*replaced"
content = "replaced {{ value }}"

[[rules]]
type = "prepend"
path = "{{ dir }}/some.txt"
content = "prepend {{ value }}"

[[rules]]
type = "append"
path = "{{ dir }}/some.txt"
content = "append {{ value }}"
genify example.toml

tmp/some.txt

prepend value
val value Val 1 - replaced value
append value

Code

fn main() {
    genify::generate(
        Path::new("."),
        &genify::parse_toml(
            fs::read_to_string("xtask/templates/controller.toml")
                .unwrap()
                .as_str(),
        )
        .expect("Cannot parse the controller.toml"),
        Some(vec![(
            "name".to_string(),
            genify::Value::String(name.clone()),
        )]),
    )
    .expect("Cannot generate the controller");
}

License

Contribution

CONTRIBUTING.md

Dependencies

~9–19MB
~242K SLoC