Skip to content

Commit def7684

Browse files
authored
fix(cli.rs): do not prompt for init values if arg set (#3400)
1 parent ffb9a19 commit def7684

2 files changed

Lines changed: 34 additions & 23 deletions

File tree

.changes/fix-cli-prompts.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"cli.rs": patch
3+
---
4+
5+
Fix `init` command prompting for values even if the argument has been provided on the command line.

tooling/cli/src/init.rs

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -90,29 +90,35 @@ impl Options {
9090
Default::default()
9191
};
9292

93-
self.app_name = self.app_name.or(request_input(
94-
"What is your app name?",
95-
init_defaults.app_name.clone(),
96-
self.ci,
97-
)?);
98-
99-
self.window_title = self.window_title.or(request_input(
100-
"What should the window title be?",
101-
init_defaults.app_name.clone(),
102-
self.ci,
103-
)?);
104-
105-
self.dist_dir = self.dist_dir
106-
.or(request_input(
107-
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?"#,
108-
init_defaults.framework.as_ref().map(|f| f.dist_dir()),
109-
self.ci)?);
110-
111-
self.dev_path = self.dev_path.or(request_input(
112-
"What is the url of your dev server?",
113-
init_defaults.framework.map(|f| f.dev_path()),
114-
self.ci,
115-
)?);
93+
self.app_name = self.app_name.map(|s| Ok(Some(s))).unwrap_or_else(|| {
94+
request_input(
95+
"What is your app name?",
96+
init_defaults.app_name.clone(),
97+
self.ci,
98+
)
99+
})?;
100+
101+
self.window_title = self.window_title.map(|s| Ok(Some(s))).unwrap_or_else(|| {
102+
request_input(
103+
"What should the window title be?",
104+
init_defaults.app_name.clone(),
105+
self.ci,
106+
)
107+
})?;
108+
109+
self.dist_dir = self.dist_dir.map(|s| Ok(Some(s))).unwrap_or_else(|| request_input(
110+
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?"#,
111+
init_defaults.framework.as_ref().map(|f| f.dist_dir()),
112+
self.ci
113+
))?;
114+
115+
self.dev_path = self.dev_path.map(|s| Ok(Some(s))).unwrap_or_else(|| {
116+
request_input(
117+
"What is the url of your dev server?",
118+
init_defaults.framework.map(|f| f.dev_path()),
119+
self.ci,
120+
)
121+
})?;
116122

117123
Ok(self)
118124
}

0 commit comments

Comments
 (0)