mirror of
https://github.com/dexoron/dcr.git
synced 2026-10-21 19:39:31 +00:00
Compare commits
1 Commits
master
...
cf634d8a8b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cf634d8a8b |
10
Cargo.lock
generated
10
Cargo.lock
generated
@@ -777,15 +777,6 @@ version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e"
|
||||
|
||||
[[package]]
|
||||
name = "openssl-src"
|
||||
version = "300.6.0+3.6.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a8e8cbfd3a4a8c8f089147fd7aaa33cf8c7450c4d09f8f80698a0cf093abeff4"
|
||||
dependencies = [
|
||||
"cc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "openssl-sys"
|
||||
version = "0.9.115"
|
||||
@@ -794,7 +785,6 @@ checksum = "158fe5b292746440aa6e7a7e690e55aeb72d41505e2804c23c6973ad0e9c9781"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
"openssl-src",
|
||||
"pkg-config",
|
||||
"vcpkg",
|
||||
]
|
||||
|
||||
@@ -19,4 +19,4 @@ serde_json = "1"
|
||||
ctrlc = "3"
|
||||
|
||||
[target.'cfg(not(windows))'.dependencies]
|
||||
openssl = { version = "0.10", features = ["vendored"] }
|
||||
openssl = { version = "0.10" }
|
||||
|
||||
2
rust-toolchain.toml
Normal file
2
rust-toolchain.toml
Normal file
@@ -0,0 +1,2 @@
|
||||
[toolchain]
|
||||
channel = "nightly"
|
||||
56
src/cli/fmt.rs
Normal file
56
src/cli/fmt.rs
Normal file
@@ -0,0 +1,56 @@
|
||||
use crate::utils::log::error;
|
||||
use crate::utils::text::{colored, BOLD_GREEN};
|
||||
use glob::glob;
|
||||
use std::process::Command;
|
||||
|
||||
pub fn fmt(_args: &[String]) -> i32 {
|
||||
let patterns = [
|
||||
"src/**/*.c",
|
||||
"src/**/*.cpp",
|
||||
"src/**/*.h",
|
||||
"src/**/*.hpp",
|
||||
"tests/**/*.c",
|
||||
"tests/**/*.cpp",
|
||||
"tests/**/*.h",
|
||||
"tests/**/*.hpp",
|
||||
];
|
||||
|
||||
let mut files = Vec::new();
|
||||
for pattern in patterns {
|
||||
if let Ok(paths) = glob(pattern) {
|
||||
for path in paths.flatten() {
|
||||
if let Some(s) = path.to_str() {
|
||||
files.push(s.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if files.is_empty() {
|
||||
println!(" {} No files to format", colored("Format", BOLD_GREEN));
|
||||
return 0;
|
||||
}
|
||||
|
||||
println!(
|
||||
" {} {} files",
|
||||
colored("Formatting", BOLD_GREEN),
|
||||
files.len()
|
||||
);
|
||||
|
||||
let status = Command::new("clang-format").arg("-i").args(&files).status();
|
||||
|
||||
match status {
|
||||
Ok(s) if s.success() => {
|
||||
println!(" {} successful", colored("Format", BOLD_GREEN));
|
||||
0
|
||||
}
|
||||
Ok(s) => {
|
||||
error(&format!("clang-format failed with status: {}", s));
|
||||
1
|
||||
}
|
||||
Err(e) => {
|
||||
error(&format!("Failed to execute clang-format: {}", e));
|
||||
1
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ pub fn help() -> i32 {
|
||||
println!(" run [--profile] Build and run the project (default: --debug)");
|
||||
println!(" tree Display the dependency tree");
|
||||
println!(" test Run project tests (alias: tests)");
|
||||
println!(" fmt Format all C/C++ source files using clang-format");
|
||||
println!(" clean Remove the target directory");
|
||||
println!(" gen <subcommand> Generate IDE integration files");
|
||||
printc("FLAGS:", BOLD_GREEN);
|
||||
|
||||
@@ -3,6 +3,7 @@ pub mod build;
|
||||
pub mod clean;
|
||||
pub mod flag_update;
|
||||
pub mod flags;
|
||||
pub mod fmt;
|
||||
pub mod r#gen;
|
||||
pub mod help;
|
||||
pub mod init;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#![feature(let_chains)]
|
||||
use crate::utils::log::error;
|
||||
mod cli;
|
||||
mod config;
|
||||
@@ -24,6 +25,7 @@ fn main() {
|
||||
"run" => cli::run::run(rest),
|
||||
"tree" => cli::tree::tree(rest),
|
||||
"test" | "tests" => cli::test::test(rest),
|
||||
"fmt" => cli::fmt::fmt(rest),
|
||||
"clean" => cli::clean::clean(rest),
|
||||
"gen" => cli::r#gen::r#gen(rest),
|
||||
"--version" => {
|
||||
|
||||
Reference in New Issue
Block a user