diff --git a/clippy.toml b/clippy.toml index 756c7dc2..15906305 100644 --- a/clippy.toml +++ b/clippy.toml @@ -1 +1 @@ -too-many-arguments-threshold = 9 +too-many-arguments-threshold = 10 diff --git a/src/command/format.rs b/src/command/format.rs index 409d8098..16b7e97d 100644 --- a/src/command/format.rs +++ b/src/command/format.rs @@ -9,6 +9,7 @@ pub fn format_cmd( work_dir: &Path, config_file: &Path, paths: &[PathBuf], + hidden: bool, no_cache: bool, clear_cache: bool, fail_on_change: bool, @@ -55,6 +56,7 @@ pub fn format_cmd( &cache_dir, config_file, &paths, + hidden, no_cache, clear_cache, fail_on_change, diff --git a/src/command/mod.rs b/src/command/mod.rs index ab39d362..8a18d5f5 100644 --- a/src/command/mod.rs +++ b/src/command/mod.rs @@ -22,7 +22,7 @@ use std::{ #[derive(Parser, Debug)] #[command(author, version, about, long_about = None)] pub struct Cli { - /// Create a new treefmt.toml + /// Create a new treefmt.toml. #[arg(short, long, default_value_t = false)] pub init: bool, @@ -38,6 +38,15 @@ pub struct Cli { #[arg(short, long, default_value_t = false)] pub clear_cache: bool, + #[arg(long = "hidden", short = 'H')] + /// Include hidden files while traversing the tree. + /// Override with the --no-hidden flag. + pub hidden: bool, + /// Overrides the hidden flag. + /// Don't include hidden files while traversing the tree. + #[arg(long, overrides_with = "hidden", hide = true)] + no_hidden: bool, + /// Exit with error if any changes were made. Useful for CI. #[arg( long, @@ -51,7 +60,7 @@ pub struct Cli { #[arg(long, default_value_t = false)] pub allow_missing_formatter: bool, - /// Log verbosity is based off the number of v used + /// Log verbosity is based off the number of v used. #[clap(flatten)] pub verbose: Verbosity, @@ -145,6 +154,7 @@ pub fn run_cli(cli: &Cli) -> anyhow::Result<()> { &cli.work_dir, config_file, &cli.paths, + cli.hidden, cli.no_cache, cli.clear_cache, cli.fail_on_change, diff --git a/src/engine.rs b/src/engine.rs index c0b7a314..44b87eb5 100644 --- a/src/engine.rs +++ b/src/engine.rs @@ -28,6 +28,7 @@ pub fn run_treefmt( cache_dir: &Path, treefmt_toml: &Path, paths: &[PathBuf], + hidden: bool, no_cache: bool, clear_cache: bool, fail_on_change: bool, @@ -146,6 +147,7 @@ pub fn run_treefmt( for path in paths[1..].iter() { builder.add(path); } + builder.hidden(!hidden); // TODO: builder has a lot of interesting options. // TODO: use build_parallel with a Visitor. // See https://docs.rs/ignore/0.4.17/ignore/struct.WalkParallel.html#method.visit