Skip to content

Commit

Permalink
fix(cli.rs): do not prompt for init values if arg set (#3400)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog authored Feb 11, 2022
1 parent ffb9a19 commit def7684
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 23 deletions.
5 changes: 5 additions & 0 deletions .changes/fix-cli-prompts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"cli.rs": patch
---

Fix `init` command prompting for values even if the argument has been provided on the command line.
52 changes: 29 additions & 23 deletions tooling/cli/src/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,29 +90,35 @@ impl Options {
Default::default()
};

self.app_name = self.app_name.or(request_input(
"What is your app name?",
init_defaults.app_name.clone(),
self.ci,
)?);

self.window_title = self.window_title.or(request_input(
"What should the window title be?",
init_defaults.app_name.clone(),
self.ci,
)?);

self.dist_dir = self.dist_dir
.or(request_input(
r#"Where are your web assets (HTML/CSS/JS) located, relative to the "<current dir>/src-tauri/tauri.conf.json" file that will be created?"#,
init_defaults.framework.as_ref().map(|f| f.dist_dir()),
self.ci)?);

self.dev_path = self.dev_path.or(request_input(
"What is the url of your dev server?",
init_defaults.framework.map(|f| f.dev_path()),
self.ci,
)?);
self.app_name = self.app_name.map(|s| Ok(Some(s))).unwrap_or_else(|| {
request_input(
"What is your app name?",
init_defaults.app_name.clone(),
self.ci,
)
})?;

self.window_title = self.window_title.map(|s| Ok(Some(s))).unwrap_or_else(|| {
request_input(
"What should the window title be?",
init_defaults.app_name.clone(),
self.ci,
)
})?;

self.dist_dir = self.dist_dir.map(|s| Ok(Some(s))).unwrap_or_else(|| request_input(
r#"Where are your web assets (HTML/CSS/JS) located, relative to the "<current dir>/src-tauri/tauri.conf.json" file that will be created?"#,
init_defaults.framework.as_ref().map(|f| f.dist_dir()),
self.ci
))?;

self.dev_path = self.dev_path.map(|s| Ok(Some(s))).unwrap_or_else(|| {
request_input(
"What is the url of your dev server?",
init_defaults.framework.map(|f| f.dev_path()),
self.ci,
)
})?;

Ok(self)
}
Expand Down

0 comments on commit def7684

Please sign in to comment.