mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-23 04:33:06 +00:00
Minor fixes in cli (#1837)
* not using bin, until needed also removes an unnecessary warning! * removed redundant line maybe, it was readability? * using same `if let` pattern as below * to `get_bin(args.bin)?` with `Ok(())` at last * unreachable!
This commit is contained in:
parent
0feca31a4a
commit
1db8bd7edd
3 changed files with 40 additions and 40 deletions
|
@ -23,16 +23,16 @@ impl Serve {
|
|||
crate_config.with_release(self.serve.release);
|
||||
crate_config.with_verbose(self.serve.verbose);
|
||||
|
||||
if self.serve.example.is_some() {
|
||||
crate_config.as_example(self.serve.example.unwrap());
|
||||
if let Some(example) = self.serve.example {
|
||||
crate_config.as_example(example);
|
||||
}
|
||||
|
||||
if self.serve.profile.is_some() {
|
||||
crate_config.set_profile(self.serve.profile.unwrap());
|
||||
if let Some(profile) = self.serve.profile {
|
||||
crate_config.set_profile(profile);
|
||||
}
|
||||
|
||||
if self.serve.features.is_some() {
|
||||
crate_config.set_features(self.serve.features.unwrap());
|
||||
if let Some(features) = self.serve.features {
|
||||
crate_config.set_features(features);
|
||||
}
|
||||
|
||||
if let Some(target) = self.serve.target {
|
||||
|
|
|
@ -25,7 +25,6 @@ pub fn set_up_logging() {
|
|||
colors_line.get_color(&record.level()).to_fg_str()
|
||||
),
|
||||
level = colors_level.color(record.level()),
|
||||
message = message,
|
||||
));
|
||||
})
|
||||
.level(match std::env::var("DIOXUS_LOG") {
|
||||
|
|
|
@ -43,39 +43,11 @@ async fn main() -> anyhow::Result<()> {
|
|||
|
||||
set_up_logging();
|
||||
|
||||
let bin = get_bin(args.bin);
|
||||
|
||||
if let Ok(bin) = &bin {
|
||||
let _dioxus_config = DioxusConfig::load(Some(bin.clone()))
|
||||
.map_err(|e| anyhow!("Failed to load Dioxus config because: {e}"))?
|
||||
.unwrap_or_else(|| {
|
||||
log::info!("You appear to be creating a Dioxus project from scratch; we will use the default config");
|
||||
DioxusConfig::default()
|
||||
});
|
||||
|
||||
#[cfg(feature = "plugin")]
|
||||
PluginManager::init(_dioxus_config.plugin)
|
||||
.map_err(|e| anyhow!("🚫 Plugin system initialization failed: {e}"))?;
|
||||
}
|
||||
|
||||
match args.action {
|
||||
Translate(opts) => opts
|
||||
.translate()
|
||||
.map_err(|e| anyhow!("🚫 Translation of HTML into RSX failed: {}", e)),
|
||||
|
||||
Build(opts) if bin.is_ok() => opts
|
||||
.build(Some(bin.unwrap().clone()), None)
|
||||
.map_err(|e| anyhow!("🚫 Building project failed: {}", e)),
|
||||
|
||||
Clean(opts) if bin.is_ok() => opts
|
||||
.clean(Some(bin.unwrap().clone()))
|
||||
.map_err(|e| anyhow!("🚫 Cleaning project failed: {}", e)),
|
||||
|
||||
Serve(opts) if bin.is_ok() => opts
|
||||
.serve(Some(bin.unwrap().clone()))
|
||||
.await
|
||||
.map_err(|e| anyhow!("🚫 Serving project failed: {}", e)),
|
||||
|
||||
Create(opts) => opts
|
||||
.create()
|
||||
.map_err(|e| anyhow!("🚫 Creating new project failed: {}", e)),
|
||||
|
@ -84,10 +56,6 @@ async fn main() -> anyhow::Result<()> {
|
|||
.config()
|
||||
.map_err(|e| anyhow!("🚫 Configuring new project failed: {}", e)),
|
||||
|
||||
Bundle(opts) if bin.is_ok() => opts
|
||||
.bundle(Some(bin.unwrap().clone()))
|
||||
.map_err(|e| anyhow!("🚫 Bundling project failed: {}", e)),
|
||||
|
||||
#[cfg(feature = "plugin")]
|
||||
Plugin(opts) => opts
|
||||
.plugin()
|
||||
|
@ -110,6 +78,39 @@ async fn main() -> anyhow::Result<()> {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
_ => Err(anyhow::anyhow!(bin.unwrap_err())),
|
||||
action => {
|
||||
let bin = get_bin(args.bin)?;
|
||||
let _dioxus_config = DioxusConfig::load(Some(bin.clone()))
|
||||
.map_err(|e| anyhow!("Failed to load Dioxus config because: {e}"))?
|
||||
.unwrap_or_else(|| {
|
||||
log::info!("You appear to be creating a Dioxus project from scratch; we will use the default config");
|
||||
DioxusConfig::default()
|
||||
});
|
||||
|
||||
#[cfg(feature = "plugin")]
|
||||
PluginManager::init(_dioxus_config.plugin)
|
||||
.map_err(|e| anyhow!("🚫 Plugin system initialization failed: {e}"))?;
|
||||
|
||||
match action {
|
||||
Build(opts) => opts
|
||||
.build(Some(bin.clone()), None)
|
||||
.map_err(|e| anyhow!("🚫 Building project failed: {}", e)),
|
||||
|
||||
Clean(opts) => opts
|
||||
.clean(Some(bin.clone()))
|
||||
.map_err(|e| anyhow!("🚫 Cleaning project failed: {}", e)),
|
||||
|
||||
Serve(opts) => opts
|
||||
.serve(Some(bin.clone()))
|
||||
.await
|
||||
.map_err(|e| anyhow!("🚫 Serving project failed: {}", e)),
|
||||
|
||||
Bundle(opts) => opts
|
||||
.bundle(Some(bin.clone()))
|
||||
.map_err(|e| anyhow!("🚫 Bundling project failed: {}", e)),
|
||||
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue