Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

Disallow templates with generate site #789

Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,17 +390,21 @@ fn run() -> Result<(), failure::Error> {
} else if let Some(matches) = matches.subcommand_matches("generate") {
let name = matches.value_of("name").unwrap_or("worker");
let site = matches.is_present("site");
let template = matches.value_of("template");
let mut target_type = None;

let template = if site {
if template.is_some() {
failure::bail!("You cannot specify a template when generating a Workers Site. If you'd like to use the default site boilerplate, run wrangler generate --site. If you'd like to use another site boilerplate, omit the --site when running wrangler generate.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol i'm still on this, something seems off here

"You cannot specify a template when generating a Workers Site. If you'd like to use the default site boilerplate, run wrangler generate --site. If you'd like to use another site boilerplate, omit the --site when running wrangler generate."

I think if we change the bolded part to "You've passed both --site and a template to wrangler generate- however you can only pass one or the other."

what do you think?

}
"https://github.com/cloudflare/worker-sites-template"
} else {
if let Some(type_value) = matches.value_of("type") {
target_type = Some(TargetType::from_str(&type_value.to_lowercase())?);
}

let default_template = "https://github.com/cloudflare/worker-template";
let template = matches.value_of("template").unwrap_or(match target_type {
let template = template.unwrap_or(match target_type {
Some(ref pt) => match pt {
TargetType::Rust => "https://github.com/cloudflare/rustwasm-worker-template",
_ => default_template,
Expand Down