Skip to content

Commit 39a8312

Browse files
authored
Merge pull request #210 from noahbald/feat/181-update-hidden-file-handling
feat: #181 create separate `hidden` and `no-ignore` cli flags
2 parents 6b638ad + a6a06a1 commit 39a8312

File tree

4 files changed

+41
-5
lines changed

4 files changed

+41
-5
lines changed

crates/oxvg/src/commands/format.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,19 @@ pub struct Format {
3232
/// If the path is a directory, whether to walk through and optimise its subdirectories
3333
#[clap(long, short, default_value = "false")]
3434
pub recursive: bool,
35-
/// Search through hidden files and directories
35+
/// Search through hidden files and directories.
36+
///
37+
/// A file or directory is considered hidden if its base name starts with a '.' or if the operating
38+
/// system provides a "hidden" file attribute.
39+
///
40+
/// Ignored files will continue to be skipped and can be enabled with the `--no-ignore` flag.
3641
#[clap(long, short = '.', default_value = "false")]
3742
pub hidden: bool,
43+
/// When set, patterns defined in files such as `.gitigore` will be disregarded.
44+
///
45+
/// Hidden files will continue to be skipped and can be enabled with the `--hidden` flag.
46+
#[clap(long, default_value = "false")]
47+
pub no_ignore: bool,
3848
/// Sets the approximate number of threads to use. A value of 0 (default) will automatically determine the appropriate number
3949
#[clap(long, short, default_value = "0")]
4050
pub threads: usize,
@@ -53,6 +63,7 @@ impl RunCommand for Format {
5363
output: self.output.as_ref().and_then(|output| output.first()),
5464
recursive: self.recursive,
5565
hidden: self.hidden,
66+
no_ignore: self.no_ignore,
5667
threads: self.threads,
5768
};
5869
let error = Arc::new(AtomicBool::new(false));

crates/oxvg/src/commands/lint.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,19 @@ pub struct Check {
1818
/// If the path is a directory, whether to walk through and optimise its subdirectories
1919
#[clap(long, short, default_value = "false")]
2020
pub recursive: bool,
21-
/// Search through hidden files and directories
21+
/// Search through hidden files and directories.
22+
///
23+
/// A file or directory is considered hidden if its base name starts with a '.' or if the operating
24+
/// system provides a "hidden" file attribute.
25+
///
26+
/// Ignored files will continue to be skipped and can be enabled with the `--no-ignore` flag.
2227
#[clap(long, short = '.', default_value = "false")]
2328
pub hidden: bool,
29+
/// When set, patterns defined in files such as `.gitigore` will be disregarded.
30+
///
31+
/// Hidden files will continue to be skipped and can be enabled with the `--hidden` flag.
32+
#[clap(long, default_value = "false")]
33+
pub no_ignore: bool,
2434
/// Sets the approximate number of threads to use. A value of 0 (default) will automatically determine the appropriate number
2535
#[clap(long, short, default_value = "0")]
2636
pub threads: usize,
@@ -40,6 +50,7 @@ impl Check {
4050
output: None,
4151
recursive: self.recursive,
4252
hidden: self.hidden,
53+
no_ignore: self.no_ignore,
4354
threads: self.threads,
4455
};
4556
walk.run(|| {

crates/oxvg/src/commands/optimise.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,19 @@ pub struct Optimise {
3333
/// If the path is a directory, whether to walk through and optimise its subdirectories
3434
#[clap(long, short, default_value = "false")]
3535
pub recursive: bool,
36-
/// Search through hidden files and directories
36+
/// Search through hidden files and directories.
37+
///
38+
/// A file or directory is considered hidden if its base name starts with a '.' or if the operating
39+
/// system provides a "hidden" file attribute.
40+
///
41+
/// Ignored files will continue to be skipped and can be enabled with the `--no-ignore` flag.
3742
#[clap(long, short = '.', default_value = "false")]
3843
pub hidden: bool,
44+
/// When set, patterns defined in files such as `.gitigore` will be disregarded.
45+
///
46+
/// Hidden files will continue to be skipped and can be enabled with the `--hidden` flag.
47+
#[clap(long, default_value = "false")]
48+
pub no_ignore: bool,
3949
/// Sets the approximate number of threads to use. A value of 0 (default) will automatically determine the appropriate number
4050
#[clap(long, short, default_value = "0")]
4151
pub threads: usize,
@@ -80,6 +90,7 @@ impl Optimise {
8090
output: self.output.as_ref().and_then(|output| output.first()),
8191
recursive: self.recursive,
8292
hidden: self.hidden,
93+
no_ignore: self.no_ignore,
8394
threads: self.threads,
8495
};
8596
walk.run(move || {

crates/oxvg/src/walk.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ pub struct Walk<'a> {
2323
pub recursive: bool,
2424
/// Whether to search through hidden files and directories
2525
pub hidden: bool,
26+
/// Whether to disregard ignore patterns
27+
pub no_ignore: bool,
2628
/// Sets the approximate number of threads to use. A value of 0 will
2729
/// automatically determine the appropriate number
2830
pub threads: usize,
@@ -114,11 +116,12 @@ impl Walk<'_> {
114116
})
115117
})
116118
};
119+
dbg!(&self.no_ignore);
117120
WalkBuilder::new(path)
118121
.max_depth(if self.recursive { None } else { Some(1) })
119122
.hidden(!self.hidden)
120-
.git_ignore(!self.hidden)
121-
.ignore(!self.hidden)
123+
.git_ignore(!self.no_ignore)
124+
.ignore(!self.no_ignore)
122125
.follow_links(true)
123126
.threads(self.threads)
124127
.build_parallel()

0 commit comments

Comments
 (0)