From c8cb155e5a75406f09ba8f72784a15ba6e0f6938 Mon Sep 17 00:00:00 2001 From: Dexoron Date: Sat, 6 Jun 2026 21:22:46 +0800 Subject: [PATCH] feat: update help flag --- src/cli/add.rs | 7 +++++-- src/cli/build.rs | 7 +++++-- src/cli/clean.rs | 7 +++++-- src/cli/flag_update.rs | 2 +- src/cli/fmt.rs | 2 +- src/cli/init.rs | 4 ++-- src/cli/new.rs | 4 ++-- src/cli/run.rs | 7 +++++-- src/cli/setup.rs | 2 +- src/cli/tree.rs | 2 +- 10 files changed, 28 insertions(+), 16 deletions(-) diff --git a/src/cli/add.rs b/src/cli/add.rs index 109c801..2f9a3e9 100644 --- a/src/cli/add.rs +++ b/src/cli/add.rs @@ -34,9 +34,12 @@ pub struct AddArgs { } pub fn add(args: &[String]) -> i32 { - if args.first().map_or(false, |a| a == "--help") { + if args.first().is_some_and(|a| a == "--help") { printc("USAGE:", BOLD_GREEN); - printc(" dcr add [--branch ] [--tag ] [--rev ]", BOLD_CYAN); + printc( + " dcr add [--branch ] [--tag ] [--rev ]", + BOLD_CYAN, + ); println!(); printc("DESCRIPTION:", BOLD_GREEN); println!(" Adds a dependency to the project."); diff --git a/src/cli/build.rs b/src/cli/build.rs index 92ade3c..5bf8223 100644 --- a/src/cli/build.rs +++ b/src/cli/build.rs @@ -42,9 +42,12 @@ static BUILD_INTERRUPTED: AtomicBool = AtomicBool::new(false); static SIGNAL_HANDLER: Once = Once::new(); pub fn build(args: &[String]) -> i32 { - if args.first().map_or(false, |a| a == "--help") { + if args.first().is_some_and(|a| a == "--help") { printc("USAGE:", BOLD_GREEN); - printc(" dcr build [--debug | --release] [--target ] [--force] [--clean] [--verbose]", BOLD_CYAN); + printc( + " dcr build [--debug | --release] [--target ] [--force] [--clean] [--verbose]", + BOLD_CYAN, + ); println!(); printc("DESCRIPTION:", BOLD_GREEN); println!(" Compiles the project. Default profile is --debug."); diff --git a/src/cli/clean.rs b/src/cli/clean.rs index 9d91d87..931b1ed 100644 --- a/src/cli/clean.rs +++ b/src/cli/clean.rs @@ -27,9 +27,12 @@ use std::fs; use std::path::Path; pub fn clean(args: &[String]) -> i32 { - if args.first().map_or(false, |a| a == "--help") { + if args.first().is_some_and(|a| a == "--help") { printc("USAGE:", BOLD_GREEN); - printc(" dcr clean [--debug | --release] [--target ] [--all]", BOLD_CYAN); + printc( + " dcr clean [--debug | --release] [--target ] [--all]", + BOLD_CYAN, + ); println!(); printc("DESCRIPTION:", BOLD_GREEN); println!(" Removes build artifacts from the target directory."); diff --git a/src/cli/flag_update.rs b/src/cli/flag_update.rs index 31f3bfb..5d54dc9 100644 --- a/src/cli/flag_update.rs +++ b/src/cli/flag_update.rs @@ -40,7 +40,7 @@ struct ReleaseAsset { } pub fn flag_update(args: &[String]) -> i32 { - if args.first().map_or(false, |a| a == "--help") { + if args.first().is_some_and(|a| a == "--help") { printc("USAGE:", BOLD_GREEN); printc(" dcr --update", BOLD_CYAN); println!(); diff --git a/src/cli/fmt.rs b/src/cli/fmt.rs index 4086e95..551eae1 100644 --- a/src/cli/fmt.rs +++ b/src/cli/fmt.rs @@ -21,7 +21,7 @@ use glob::glob; use std::process::Command; pub fn fmt(args: &[String]) -> i32 { - if args.first().map_or(false, |a| a == "--help") { + if args.first().is_some_and(|a| a == "--help") { printc("USAGE:", BOLD_GREEN); printc(" dcr fmt", BOLD_CYAN); println!(); diff --git a/src/cli/init.rs b/src/cli/init.rs index 6adc96d..28fa7d3 100644 --- a/src/cli/init.rs +++ b/src/cli/init.rs @@ -16,7 +16,7 @@ // along with this program. If not, see . use crate::config::FILE_MAIN_C; -use crate::core::config::{validate_package_name, Config}; +use crate::core::config::{Config, validate_package_name}; use crate::utils::fs::check_dir; use crate::utils::log::{error, warn}; use crate::utils::text::{BOLD_CYAN, BOLD_GREEN, colored, printc}; @@ -25,7 +25,7 @@ use std::io::Write; use toml::Value; pub fn init(args: &[String]) -> i32 { - if args.first().map_or(false, |a| a == "--help") { + if args.first().is_some_and(|a| a == "--help") { printc("USAGE:", BOLD_GREEN); printc(" dcr init", BOLD_CYAN); println!(); diff --git a/src/cli/new.rs b/src/cli/new.rs index 943ecb1..661c610 100644 --- a/src/cli/new.rs +++ b/src/cli/new.rs @@ -16,7 +16,7 @@ // along with this program. If not, see . use crate::config::FILE_MAIN_C; -use crate::core::config::{validate_package_name, Config}; +use crate::core::config::{Config, validate_package_name}; use crate::utils::fs::check_dir; use crate::utils::log::{error, warn}; use crate::utils::text::{BOLD_CYAN, BOLD_GREEN, colored, printc}; @@ -25,7 +25,7 @@ use std::io::Write; use toml::Value; pub fn new(args: &[String]) -> i32 { - if args.first().map_or(false, |a| a == "--help") { + if args.first().is_some_and(|a| a == "--help") { printc("USAGE:", BOLD_GREEN); printc(" dcr new ", BOLD_CYAN); println!(); diff --git a/src/cli/run.rs b/src/cli/run.rs index 45c149f..70c2218 100644 --- a/src/cli/run.rs +++ b/src/cli/run.rs @@ -56,9 +56,12 @@ fn get_run_cmd( } pub fn run(args: &[String]) -> i32 { - if args.first().map_or(false, |a| a == "--help") { + if args.first().is_some_and(|a| a == "--help") { printc("USAGE:", BOLD_GREEN); - printc(" dcr run [--debug | --release] [--target ] [--force] [--clean] [--verbose]", BOLD_CYAN); + printc( + " dcr run [--debug | --release] [--target ] [--force] [--clean] [--verbose]", + BOLD_CYAN, + ); println!(); printc("DESCRIPTION:", BOLD_GREEN); println!(" Builds and runs the project. Only available for kind = \"bin\"."); diff --git a/src/cli/setup.rs b/src/cli/setup.rs index 75d3d9f..5adcc4a 100644 --- a/src/cli/setup.rs +++ b/src/cli/setup.rs @@ -18,7 +18,7 @@ use crate::utils::text::{BOLD_CYAN, BOLD_GREEN, printc}; pub fn setup(args: &[String]) -> i32 { - if args.first().map_or(false, |a| a == "--help") { + if args.first().is_some_and(|a| a == "--help") { printc("USAGE:", BOLD_GREEN); printc(" dcr setup", BOLD_CYAN); println!(); diff --git a/src/cli/tree.rs b/src/cli/tree.rs index d8e6bcd..724bb16 100644 --- a/src/cli/tree.rs +++ b/src/cli/tree.rs @@ -23,7 +23,7 @@ use std::path::{Path, PathBuf}; use toml::Value; pub fn tree(args: &[String]) -> i32 { - if args.first().map_or(false, |a| a == "--help") { + if args.first().is_some_and(|a| a == "--help") { printc("USAGE:", BOLD_GREEN); printc(" dcr tree", BOLD_CYAN); println!();