mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-10 06:34:20 +00:00
chore(cli): optimized args handling for init & new (#2418)
This commit is contained in:
parent
16313894da
commit
e69c69abd7
2 changed files with 11 additions and 17 deletions
|
@ -28,24 +28,20 @@ pub struct Create {
|
|||
|
||||
impl Create {
|
||||
pub fn create(self) -> Result<()> {
|
||||
let mut args = GenerateArgs {
|
||||
let args = GenerateArgs {
|
||||
define: self.option,
|
||||
name: self.name,
|
||||
silent: self.yes,
|
||||
template_path: TemplatePath {
|
||||
auto_path: Some(self.template),
|
||||
subfolder: self.subtemplate,
|
||||
..Default::default()
|
||||
},
|
||||
define: self.option,
|
||||
..Default::default()
|
||||
};
|
||||
if self.yes {
|
||||
if self.name.is_none() {
|
||||
return Err(
|
||||
"You have to provide the project's name when using `--yes` option.".into(),
|
||||
);
|
||||
}
|
||||
args.silent = true;
|
||||
if self.yes && args.name.is_none() {
|
||||
return Err("You have to provide the project's name when using `--yes` option.".into());
|
||||
}
|
||||
args.name = self.name;
|
||||
let path = cargo_generate::generate(args)?;
|
||||
post_create(&path)
|
||||
}
|
||||
|
|
|
@ -29,20 +29,18 @@ impl Init {
|
|||
let name = std::env::current_dir()?
|
||||
.file_name()
|
||||
.map(|f| f.to_str().unwrap().to_string());
|
||||
let mut args = GenerateArgs {
|
||||
let args = GenerateArgs {
|
||||
define: self.option,
|
||||
init: true,
|
||||
name,
|
||||
silent: self.yes,
|
||||
template_path: TemplatePath {
|
||||
auto_path: Some(self.template),
|
||||
subfolder: self.subtemplate,
|
||||
..Default::default()
|
||||
},
|
||||
name,
|
||||
init: true,
|
||||
define: self.option,
|
||||
..Default::default()
|
||||
};
|
||||
if self.yes {
|
||||
args.silent = true;
|
||||
}
|
||||
let path = cargo_generate::generate(args)?;
|
||||
create::post_create(&path)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue