Skip to content

Commit 79ad6e6

Browse files
committed
feat(generate): add preact-rx template option
1 parent 13fe324 commit 79ad6e6

4 files changed

Lines changed: 20 additions & 0 deletions

File tree

‎.vscode/settings.json‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"deno.enable": true
3+
}

‎src/cmd/generate/mod.rs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use clap::ValueEnum;
77

88
#[derive(Debug, Clone, Copy, ValueEnum)]
99
pub enum Template {
10+
PreactRx,
1011
Preact,
1112
React,
1213
Vanilla,
@@ -15,6 +16,7 @@ pub enum Template {
1516
impl Template {
1617
fn name(&self) -> &'static str {
1718
match self {
19+
Template::PreactRx => "preact-rx",
1820
Template::Preact => "preact",
1921
Template::React => "react",
2022
Template::Vanilla => "vanilla",
@@ -42,6 +44,7 @@ pub async fn main(args: GenerateCommand) -> anyhow::Result<()> {
4244
}
4345

4446
match args.template {
47+
Template::PreactRx => templates::preact_rx::generate(&args.out_dir)?,
4548
Template::Preact => templates::preact::generate(&args.out_dir)?,
4649
Template::React => templates::react::generate(&args.out_dir)?,
4750
Template::Vanilla => templates::vanilla::generate(&args.out_dir)?,

‎src/cmd/generate/templates/mod.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
pub mod preact;
2+
pub mod preact_rx;
23
pub mod react;
34
pub mod vanilla;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
use std::fs;
2+
use std::path::Path;
3+
4+
use include_dir::include_dir;
5+
use include_dir::Dir;
6+
7+
static TEMPLATE: Dir<'_> =
8+
include_dir!("$CARGO_MANIFEST_DIR/src/cmd/generate/templates/preact/template");
9+
10+
pub fn generate(target: &Path) -> std::io::Result<()> {
11+
fs::create_dir_all(target)?;
12+
TEMPLATE.extract(target)
13+
}

0 commit comments

Comments
 (0)