fix: use clippy fix
This commit is contained in:
1 parent
66b832045a
commit
84d1867654
9 files changed
+36
-44
No files matched your search
+9
-9
@@ -157,16 +157,16 @@ pub fn build_desktop(config: &CrateConfig) -> Result<()> {
|
|||||||
file_name = name.clone();
|
file_name = name.clone();
|
||||||
config
|
config
|
||||||
.target_dir
|
.target_dir
|
||||||
.join(format!("{}", release_type))
|
.join(release_type.to_string())
|
||||||
.join(format!("{}", name))
|
.join(name.to_string())
|
||||||
}
|
}
|
||||||
crate::ExecutableType::Example(name) => {
|
crate::ExecutableType::Example(name) => {
|
||||||
file_name = name.clone();
|
file_name = name.clone();
|
||||||
config
|
config
|
||||||
.target_dir
|
.target_dir
|
||||||
.join(format!("{}", release_type))
|
.join(release_type.to_string())
|
||||||
.join("examples")
|
.join("examples")
|
||||||
.join(format!("{}", name))
|
.join(name.to_string())
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -175,7 +175,7 @@ pub fn build_desktop(config: &CrateConfig) -> Result<()> {
|
|||||||
res_path.set_extension("exe");
|
res_path.set_extension("exe");
|
||||||
target_file = format!("{}.exe", &file_name);
|
target_file = format!("{}.exe", &file_name);
|
||||||
} else {
|
} else {
|
||||||
target_file = file_name.clone();
|
target_file = file_name;
|
||||||
}
|
}
|
||||||
create_dir_all(&config.out_dir)?;
|
create_dir_all(&config.out_dir)?;
|
||||||
copy(res_path, &config.out_dir.join(target_file))?;
|
copy(res_path, &config.out_dir.join(target_file))?;
|
||||||
@@ -200,12 +200,12 @@ pub fn gen_page(config: &DioxusConfig, serve: bool) -> String {
|
|||||||
|
|
||||||
let resouces = config.web.resource.clone();
|
let resouces = config.web.resource.clone();
|
||||||
|
|
||||||
let mut style_list = resouces.style.unwrap_or(vec![]);
|
let mut style_list = resouces.style.unwrap_or_default();
|
||||||
let mut script_list = resouces.script.unwrap_or(vec![]);
|
let mut script_list = resouces.script.unwrap_or_default();
|
||||||
|
|
||||||
if serve {
|
if serve {
|
||||||
let mut dev_style = resouces.dev.style.clone().unwrap_or(vec![]);
|
let mut dev_style = resouces.dev.style.clone().unwrap_or_default();
|
||||||
let mut dev_script = resouces.dev.script.clone().unwrap_or(vec![]);
|
let mut dev_script = resouces.dev.script.unwrap_or_default();
|
||||||
style_list.append(&mut dev_style);
|
style_list.append(&mut dev_style);
|
||||||
script_list.append(&mut dev_script);
|
script_list.append(&mut dev_script);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,10 +22,8 @@ impl Build {
|
|||||||
crate_config.as_example(self.build.example.unwrap());
|
crate_config.as_example(self.build.example.unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.build.platform.is_some() {
|
if self.build.platform.is_some() && self.build.platform.unwrap().to_uppercase() == "DESKTOP" {
|
||||||
if self.build.platform.unwrap().to_uppercase() == "DESKTOP" {
|
crate::builder::build_desktop(&crate_config)?;
|
||||||
crate::builder::build_desktop(&crate_config)?;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
crate::builder::build(&crate_config)?;
|
crate::builder::build(&crate_config)?;
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ impl Config {
|
|||||||
match self {
|
match self {
|
||||||
Config::Init { name, force } => {
|
Config::Init { name, force } => {
|
||||||
let conf_path = crate_root.join("Dioxus.toml");
|
let conf_path = crate_root.join("Dioxus.toml");
|
||||||
if conf_path.is_file() && force == false {
|
if conf_path.is_file() && !force {
|
||||||
log::warn!(
|
log::warn!(
|
||||||
"config file `Dioxus.toml` already exist, use `--force` to overwrite it."
|
"config file `Dioxus.toml` already exist, use `--force` to overwrite it."
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ impl Create {
|
|||||||
meta_file = meta_file.replace("{{project-name}}", &self.name);
|
meta_file = meta_file.replace("{{project-name}}", &self.name);
|
||||||
File::create(project_path.join("Dioxus.toml"))?.write_all(meta_file.as_bytes())?;
|
File::create(project_path.join("Dioxus.toml"))?.write_all(meta_file.as_bytes())?;
|
||||||
|
|
||||||
println!("");
|
println!();
|
||||||
log::info!("💡 Project initialized:");
|
log::info!("💡 Project initialized:");
|
||||||
log::info!("🎯> cd ./{}", self.name);
|
log::info!("🎯> cd ./{}", self.name);
|
||||||
log::info!("🎯> dioxus serve");
|
log::info!("🎯> dioxus serve");
|
||||||
|
|||||||
+12
-17
@@ -21,27 +21,22 @@ impl Serve {
|
|||||||
crate_config.as_example(self.serve.example.unwrap());
|
crate_config.as_example(self.serve.example.unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.serve.platform.is_some() {
|
if self.serve.platform.is_some() && self.serve.platform.unwrap().to_uppercase() == "DESKTOP" {
|
||||||
if self.serve.platform.unwrap().to_uppercase() == "DESKTOP" {
|
crate::builder::build_desktop(&crate_config)?;
|
||||||
crate::builder::build_desktop(&crate_config)?;
|
|
||||||
|
|
||||||
match &crate_config.executable {
|
match &crate_config.executable {
|
||||||
crate::ExecutableType::Binary(name)
|
crate::ExecutableType::Binary(name)
|
||||||
| crate::ExecutableType::Lib(name)
|
| crate::ExecutableType::Lib(name)
|
||||||
| crate::ExecutableType::Example(name) => {
|
| crate::ExecutableType::Example(name) => {
|
||||||
let mut file = crate_config.out_dir.join(name);
|
let mut file = crate_config.out_dir.join(name);
|
||||||
if cfg!(windows) {
|
if cfg!(windows) {
|
||||||
file.set_extension("exe");
|
file.set_extension("exe");
|
||||||
}
|
|
||||||
Command::new(format!(
|
|
||||||
"{}",
|
|
||||||
crate_config.out_dir.join(file).to_str().unwrap()
|
|
||||||
))
|
|
||||||
.output()?;
|
|
||||||
}
|
}
|
||||||
|
Command::new(crate_config.out_dir.join(file).to_str().unwrap().to_string())
|
||||||
|
.output()?;
|
||||||
}
|
}
|
||||||
return Ok(());
|
|
||||||
}
|
}
|
||||||
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
crate::builder::build(&crate_config).expect("build failed");
|
crate::builder::build(&crate_config).expect("build failed");
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ impl Translate {
|
|||||||
exit(0);
|
exit(0);
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
if let None = temp {
|
if temp.is_none() {
|
||||||
if let Some(s) = source {
|
if let Some(s) = source {
|
||||||
contents = s;
|
contents = s;
|
||||||
} else {
|
} else {
|
||||||
@@ -112,7 +112,7 @@ fn render_child(f: &mut impl Write, child: &Node, il: u32) -> std::fmt::Result {
|
|||||||
}
|
}
|
||||||
write!(f, "\",")?;
|
write!(f, "\",")?;
|
||||||
}
|
}
|
||||||
write!(f, "\n")?;
|
writeln!(f)?;
|
||||||
|
|
||||||
// write the attributes
|
// write the attributes
|
||||||
if let Some(id) = &el.id {
|
if let Some(id) = &el.id {
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ fn render_element<'a>(
|
|||||||
}
|
}
|
||||||
write!(f, "\",")?;
|
write!(f, "\",")?;
|
||||||
}
|
}
|
||||||
write!(f, "\n")?;
|
writeln!(f)?;
|
||||||
|
|
||||||
// write the attributes
|
// write the attributes
|
||||||
if let Some(id) = &el.id {
|
if let Some(id) = &el.id {
|
||||||
|
|||||||
+7
-8
@@ -23,12 +23,12 @@ impl DioxusConfig {
|
|||||||
dioxus_conf_file.read_to_string(&mut meta_str)?;
|
dioxus_conf_file.read_to_string(&mut meta_str)?;
|
||||||
|
|
||||||
match toml::from_str::<DioxusConfig>(&meta_str) {
|
match toml::from_str::<DioxusConfig>(&meta_str) {
|
||||||
Ok(v) => return Ok(v),
|
Ok(v) => Ok(v),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
log::error!("{}", e);
|
log::error!("{}", e);
|
||||||
return Err(crate::error::Error::Unique(
|
Err(crate::error::Error::Unique(
|
||||||
"Dioxus.toml parse failed".into(),
|
"Dioxus.toml parse failed".into(),
|
||||||
));
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -147,16 +147,15 @@ impl CrateConfig {
|
|||||||
|
|
||||||
// We just assume they're using a 'main.rs'
|
// We just assume they're using a 'main.rs'
|
||||||
// Anyway, we've already parsed the manifest, so it should be easy to change the type
|
// Anyway, we've already parsed the manifest, so it should be easy to change the type
|
||||||
let output_filename = (&manifest)
|
let output_filename = manifest
|
||||||
.lib
|
.lib
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.and_then(|lib| lib.name.clone())
|
.and_then(|lib| lib.name.clone())
|
||||||
.or_else(|| {
|
.or_else(|| {
|
||||||
(&manifest)
|
manifest
|
||||||
.package
|
.package
|
||||||
.as_ref()
|
.as_ref().map(|pkg| pkg.name.clone())
|
||||||
.and_then(|pkg| Some(pkg.name.clone()))
|
|
||||||
.clone()
|
|
||||||
})
|
})
|
||||||
.expect("No lib found from cargo metadata");
|
.expect("No lib found from cargo metadata");
|
||||||
let executable = ExecutableType::Binary(output_filename);
|
let executable = ExecutableType::Binary(output_filename);
|
||||||
|
|||||||
+1
-1
@@ -14,7 +14,7 @@ pub fn set_up_logging() {
|
|||||||
// configure colors for the name of the level.
|
// configure colors for the name of the level.
|
||||||
// since almost all of them are the same as the color for the whole line, we
|
// since almost all of them are the same as the color for the whole line, we
|
||||||
// just clone `colors_line` and overwrite our changes
|
// just clone `colors_line` and overwrite our changes
|
||||||
let colors_level = colors_line.clone().info(Color::Green);
|
let colors_level = colors_line.info(Color::Green);
|
||||||
// here we set up our fern Dispatch
|
// here we set up our fern Dispatch
|
||||||
fern::Dispatch::new()
|
fern::Dispatch::new()
|
||||||
.format(move |out, message, record| {
|
.format(move |out, message, record| {
|
||||||
|
|||||||
Reference in new issue
Block a user