diff --git a/src/cli.rs b/src/cli.rs index 9c3a9a2c6..6ec128831 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -184,9 +184,21 @@ enum ComponentArg { /// Actions actions: Vec, - /// The kind of scaffold to generate - #[clap(short, long, value_enum, default_value_t = gen::ScaffoldKind::Api)] - kind: gen::ScaffoldKind, + /// The kind of controller actions to generate + #[clap(short, long, value_enum, group = "scaffold_kind_group")] + kind: Option, + + /// Use HTMX controller actions + #[clap(long, group = "scaffold_kind_group")] + htmx: bool, + + /// Use HTML controller actions + #[clap(long, group = "scaffold_kind_group")] + html: bool, + + /// Use API controller actions + #[clap(long, group = "scaffold_kind_group")] + api: bool, }, /// Generate a Task based on the given name Task { @@ -256,11 +268,30 @@ impl TryFrom for Component { name, actions, kind, - } => Ok(Self::Controller { - name, - actions, - kind, - }), + htmx, + html, + api, + } => { + let kind = if let Some(kind) = kind { + kind + } else if htmx { + ScaffoldKind::Htmx + } else if html { + ScaffoldKind::Html + } else if api { + ScaffoldKind::Api + } else { + return Err(crate::Error::string( + "Error: One of `kind`, `htmx`, `html`, or `api` must be specified.", + )); + }; + + Ok(Self::Controller { + name, + actions, + kind, + }) + } ComponentArg::Task { name } => Ok(Self::Task { name }), ComponentArg::Scheduler {} => Ok(Self::Scheduler {}), ComponentArg::Worker { name } => Ok(Self::Worker { name }), diff --git a/src/controller/fallback.html b/src/controller/fallback.html index 306e1bfee..610b6aee9 100644 --- a/src/controller/fallback.html +++ b/src/controller/fallback.html @@ -11,7 +11,7 @@
-
+