Skip to content

Commit 7533677

Browse files
authored
Merge pull request #498 from sanders41/prompts
Refactor prompts
2 parents d18f91d + f662f8a commit 7533677

File tree

1 file changed

+2
-30
lines changed

1 file changed

+2
-30
lines changed

src/project_info.rs

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -382,20 +382,12 @@ fn copyright_year_prompt(license: &LicenseType, default: Option<String>) -> Resu
382382

383383
pub fn get_project_info(use_defaults: bool) -> Result<ProjectInfo> {
384384
let config = Config::load_config();
385-
let project_name_prompt = Prompt {
386-
prompt_text: "Project Name".to_string(),
387-
default: None,
388-
};
389-
let project_name = project_name_prompt.show_prompt()?;
385+
let project_name = string_prompt("Project Name".to_string(), None)?;
390386
let project_slug_default = project_name.replace(' ', "-").to_lowercase();
391387
let project_slug = if use_defaults {
392388
project_slug_default
393389
} else {
394-
let project_slug_prompt = Prompt {
395-
prompt_text: "Project Slug".to_string(),
396-
default: Some(project_slug_default),
397-
};
398-
project_slug_prompt.show_prompt()?
390+
string_prompt("Project Slug".to_string(), Some(project_slug_default))?
399391
};
400392

401393
if Path::new(&project_slug).exists() {
@@ -630,31 +622,11 @@ pub fn get_project_info(use_defaults: bool) -> Result<ProjectInfo> {
630622

631623
let docs_info = if include_docs {
632624
let site_name = string_prompt("Docs Site Name".to_string(), None)?;
633-
if site_name.is_empty() {
634-
bail!("A site name is required for docs");
635-
}
636-
637625
let site_description = string_prompt("Docs Site Description".to_string(), None)?;
638-
if site_description.is_empty() {
639-
bail!("A site description is required for docs");
640-
}
641-
642626
let site_url = string_prompt("Docs Site Url".to_string(), None)?;
643-
if site_url.is_empty() {
644-
bail!("A site url is required for docs");
645-
}
646-
647627
let locale = string_prompt("Docs Locale".to_string(), Some("en".to_string()))?;
648-
649628
let repo_name = string_prompt("Docs Repo Name".to_string(), None)?;
650-
if repo_name.is_empty() {
651-
bail!("A repo name is required for docs");
652-
}
653-
654629
let repo_url = string_prompt("Docs Repo Url".to_string(), None)?;
655-
if repo_url.is_empty() {
656-
bail!("A repo url is required for docs");
657-
}
658630

659631
Some(DocsInfo {
660632
site_name,

0 commit comments

Comments
 (0)