diff --git a/src/cli/init/mod.rs b/src/cli/create/mod.rs similarity index 94% rename from src/cli/init/mod.rs rename to src/cli/create/mod.rs index a19ee68fd..7cb2edbbe 100644 --- a/src/cli/init/mod.rs +++ b/src/cli/create/mod.rs @@ -13,8 +13,8 @@ use crate::{error::Result, Error}; /// Build the Rust WASM app and all of its assets. #[derive(Clone, Debug, Default, Deserialize, StructOpt)] -#[structopt(name = "init")] -pub struct Init { +#[structopt(name = "create")] +pub struct Create { /// Init project name #[structopt(default_value = ".")] name: String, @@ -29,8 +29,8 @@ pub struct Init { pub lib: bool, } -impl Init { - pub fn init(self) -> Result<()> { +impl Create { + pub fn create(self) -> Result<()> { if Self::name_vaild_check(self.name.clone()) { log::error!("❗Unsupported project name."); 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") .arg("generate") diff --git a/src/cli/mod.rs b/src/cli/mod.rs index 6224cea32..91d561463 100644 --- a/src/cli/mod.rs +++ b/src/cli/mod.rs @@ -3,7 +3,7 @@ use structopt::StructOpt; pub mod build; pub mod cfg; pub mod clean; -pub mod init; +pub mod create; pub mod serve; pub mod translate; @@ -35,7 +35,7 @@ pub enum Commands { /// Build, watch & serve the Rust WASM app and all of its assets. Serve(serve::Serve), /// Init a new project for Dioxus. - Init(init::Init), + Create(create::Create), // /// Clean output artifacts. Clean(clean::Clean), // /// Trunk config controls. diff --git a/src/config.rs b/src/config.rs index ad1e25ea5..fa52ddcbc 100644 --- a/src/config.rs +++ b/src/config.rs @@ -13,8 +13,7 @@ impl DioxusConfig { let crate_dir = crate::cargo::crate_root()?; if !crate_dir.join("Dioxus.toml").is_file() { - log::warn!("Config file: `Dioxus.toml` not found."); - return Ok(Self::default()); + return Err(crate::error::Error::Unique("Config file: `Dioxus.toml` not found.".into())); } let mut dioxus_conf_file = File::open(crate_dir.join("Dioxus.toml"))?; diff --git a/src/main.rs b/src/main.rs index 70f92cf95..20536048b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -34,9 +34,9 @@ async fn main() -> Result<()> { } } - Commands::Init(opts) => { - if let Err(e) = opts.init() { - log::error!("init error: {}", e); + Commands::Create(opts) => { + if let Err(e) = opts.create() { + log::error!("create error: {}", e); } } }