| Crates.io | genify |
| lib.rs | genify |
| version | 0.0.3 |
| created_at | 2024-12-01 18:45:46.145291+00 |
| updated_at | 2025-06-04 20:38:34.186395+00 |
| description | Turn one file into a complete project |
| homepage | |
| repository | https://github.com/daxartio/genify |
| max_upload_size | |
| id | 1467735 |
| size | 95,981 |
Turn one file into a complete project
The main idea is to have a single source file that can be used to generate or update a full project structure quickly and consistently using different configuration files.
There are two modes:
Features:
cargo install genify --features cli
Turn one file into a complete project
Usage: genify [OPTIONS] <PATH>
Arguments:
<PATH> Path to a config file or http(s) URL
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
| Type | Description | CLI Interactive Support |
|---|---|---|
| String | Text value | ✅ Supported |
| Integer | Whole number | ✅ Supported |
| Float | Decimal number | ✅ Supported |
| Boolean | true or false | ✅ Supported |
| Array | List of values | ❌ Not supported |
| Map | Key-value pairs | ❌ Not supported |
Note: In interactive CLI mode, all types are supported except Array and Map, will be used default values.
fn main() {
genify::generate(
Path::new("."),
&genify::parse_toml(
fs::read_to_string("example.toml")
.unwrap()
.as_str(),
)
.expect("Cannot parse the example.toml"),
Some(vec![(
"value".to_string(),
genify::Value::String("val".to_string()),
)]),
)
.expect("Cannot generate the example");
}