refactor(build): format using cargo fmt
This commit is contained in:
parent
07380713b6
commit
acf26d6e90
1 changed files with 20 additions and 16 deletions
34
build.rs
34
build.rs
|
|
@ -1,21 +1,13 @@
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
fs::{
|
fs::{self, DirEntry, ReadDir, write},
|
||||||
self,
|
|
||||||
DirEntry,
|
|
||||||
ReadDir,
|
|
||||||
write,
|
|
||||||
},
|
|
||||||
io,
|
io,
|
||||||
path::{
|
path::{Path, PathBuf},
|
||||||
Path,
|
|
||||||
PathBuf
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const COMMAND_DIR: &str = "./src/commands/";
|
const COMMAND_DIR: &str = "./src/commands/";
|
||||||
const EVENT_DIR: &str = "./src/events";
|
const EVENT_DIR: &str = "./src/events";
|
||||||
const MOD_PREFIX: &str= "pub mod ";
|
const MOD_PREFIX: &str = "pub mod ";
|
||||||
|
|
||||||
fn clear_name(s: &mut String, n: usize) -> String {
|
fn clear_name(s: &mut String, n: usize) -> String {
|
||||||
if n >= s.len() {
|
if n >= s.len() {
|
||||||
|
|
@ -35,7 +27,10 @@ fn read_dir(dir: &Path) -> Vec<String> {
|
||||||
for entry in fs::read_dir(dir).unwrap() {
|
for entry in fs::read_dir(dir).unwrap() {
|
||||||
let entry: DirEntry = entry.unwrap();
|
let entry: DirEntry = entry.unwrap();
|
||||||
let pb: PathBuf = entry.path();
|
let pb: PathBuf = entry.path();
|
||||||
if pb.is_file() && pb.to_string_lossy().ends_with(".rs") && !pb.to_string_lossy().ends_with("mod.rs") {
|
if pb.is_file()
|
||||||
|
&& pb.to_string_lossy().ends_with(".rs")
|
||||||
|
&& !pb.to_string_lossy().ends_with("mod.rs")
|
||||||
|
{
|
||||||
dir_content.push(clear_name(pb.to_string_lossy().to_mut(), len));
|
dir_content.push(clear_name(pb.to_string_lossy().to_mut(), len));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -72,10 +67,16 @@ fn commands() -> io::Result<()> {
|
||||||
submodules = String::from(MOD_PREFIX) + command + &String::from(";\n");
|
submodules = String::from(MOD_PREFIX) + command + &String::from(";\n");
|
||||||
println!("\t'{}'", command);
|
println!("\t'{}'", command);
|
||||||
}
|
}
|
||||||
write(String::from(COMMAND_DIR) + subdir + &String::from("/mod.rs"), submodules)?;
|
write(
|
||||||
|
String::from(COMMAND_DIR) + subdir + &String::from("/mod.rs"),
|
||||||
|
submodules,
|
||||||
|
)?;
|
||||||
modules = modules + &String::from(MOD_PREFIX) + subdir + &String::from(";\n");
|
modules = modules + &String::from(MOD_PREFIX) + subdir + &String::from(";\n");
|
||||||
}
|
}
|
||||||
write(String::from(COMMAND_DIR) + &String::from("/mod.rs"), modules)?;
|
write(
|
||||||
|
String::from(COMMAND_DIR) + &String::from("/mod.rs"),
|
||||||
|
modules,
|
||||||
|
)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
@ -91,7 +92,10 @@ fn events() -> io::Result<()> {
|
||||||
submodules = String::from(MOD_PREFIX) + event + &String::from(";\n");
|
submodules = String::from(MOD_PREFIX) + event + &String::from(";\n");
|
||||||
println!("\t'{}'", event);
|
println!("\t'{}'", event);
|
||||||
}
|
}
|
||||||
write(String::from(EVENT_DIR) + subdir + &String::from("/mod.rs"), submodules)?;
|
write(
|
||||||
|
String::from(EVENT_DIR) + subdir + &String::from("/mod.rs"),
|
||||||
|
submodules,
|
||||||
|
)?;
|
||||||
modules = modules + &String::from(MOD_PREFIX) + subdir + &String::from(";\n");
|
modules = modules + &String::from(MOD_PREFIX) + subdir + &String::from(";\n");
|
||||||
}
|
}
|
||||||
write(String::from(EVENT_DIR) + &String::from("/mod.rs"), modules)?;
|
write(String::from(EVENT_DIR) + &String::from("/mod.rs"), modules)?;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue