fix: change init to create

This commit is contained in:
mrxiaozhuox committed 2022-01-24 12:16:02 +08:00
1 parent d695777402
commit 4cc7752adf
4 files changed
+11 -12

No files matched your search

@@ -13,8 +13,8 @@ use crate::{error::Result, Error};
/// Build the Rust WASM app and all of its assets. /// Build the Rust WASM app and all of its assets.
#[derive(Clone, Debug, Default, Deserialize, StructOpt)] #[derive(Clone, Debug, Default, Deserialize, StructOpt)]
#[structopt(name = "init")] #[structopt(name = "create")]
pub struct Init { pub struct Create {
/// Init project name /// Init project name
#[structopt(default_value = ".")] #[structopt(default_value = ".")]
name: String, name: String,
@@ -29,8 +29,8 @@ pub struct Init {
pub lib: bool, pub lib: bool,
} }
impl Init { impl Create {
pub fn init(self) -> Result<()> { pub fn create(self) -> Result<()> {
if Self::name_vaild_check(self.name.clone()) { if Self::name_vaild_check(self.name.clone()) {
log::error!("❗Unsupported project name."); log::error!("❗Unsupported project name.");
return Ok(()); return Ok(());
@@ -45,7 +45,7 @@ impl Init {
))); )));
} }
log::info!("🔧 Start to init a new project '{}'.", self.name); log::info!("🔧 Start to create a new project '{}'.", self.name);
let output = Command::new("cargo") let output = Command::new("cargo")
.arg("generate") .arg("generate")
+2 -2
View File
@@ -3,7 +3,7 @@ use structopt::StructOpt;
pub mod build; pub mod build;
pub mod cfg; pub mod cfg;
pub mod clean; pub mod clean;
pub mod init; pub mod create;
pub mod serve; pub mod serve;
pub mod translate; pub mod translate;
@@ -35,7 +35,7 @@ pub enum Commands {
/// Build, watch & serve the Rust WASM app and all of its assets. /// Build, watch & serve the Rust WASM app and all of its assets.
Serve(serve::Serve), Serve(serve::Serve),
/// Init a new project for Dioxus. /// Init a new project for Dioxus.
Init(init::Init), Create(create::Create),
// /// Clean output artifacts. // /// Clean output artifacts.
Clean(clean::Clean), Clean(clean::Clean),
// /// Trunk config controls. // /// Trunk config controls.
+1 -2
View File
@@ -13,8 +13,7 @@ impl DioxusConfig {
let crate_dir = crate::cargo::crate_root()?; let crate_dir = crate::cargo::crate_root()?;
if !crate_dir.join("Dioxus.toml").is_file() { if !crate_dir.join("Dioxus.toml").is_file() {
log::warn!("Config file: `Dioxus.toml` not found."); return Err(crate::error::Error::Unique("Config file: `Dioxus.toml` not found.".into()));
return Ok(Self::default());
} }
let mut dioxus_conf_file = File::open(crate_dir.join("Dioxus.toml"))?; let mut dioxus_conf_file = File::open(crate_dir.join("Dioxus.toml"))?;
+3 -3
View File
@@ -34,9 +34,9 @@ async fn main() -> Result<()> {
} }
} }
Commands::Init(opts) => { Commands::Create(opts) => {
if let Err(e) = opts.init() { if let Err(e) = opts.create() {
log::error!("init error: {}", e); log::error!("create error: {}", e);
} }
} }
} }