Skip to content

Commit

Permalink
Support for --hidden and --no-ignore Options (Closes #58)
Browse files Browse the repository at this point in the history
  • Loading branch information
mufeedvh committed Jan 15, 2025
1 parent 15ca75a commit fa72ecd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ struct Cli {
/// Follow symlinks
#[clap(short = 'f', long)]
follow_symlinks: bool,

/// Include hidden directories and files
#[clap(long)]
hidden: bool,

/// Skip .gitignore rules
#[clap(long)]
no_ignore: bool,
}

fn main() -> Result<()> {
Expand Down Expand Up @@ -126,6 +134,8 @@ fn main() -> Result<()> {
args.exclude_from_tree,
args.no_codeblock,
args.follow_symlinks,
args.hidden,
args.no_ignore,
);

let (tree, files) = match create_tree {
Expand Down
5 changes: 4 additions & 1 deletion src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ pub fn traverse_directory(
exclude_from_tree: bool,
no_codeblock: bool,
follow_symlinks: bool,
hidden: bool,
no_ignore: bool,
) -> Result<(String, Vec<serde_json::Value>)> {
// ~~~ Initialization ~~~
let mut files = Vec::new();
Expand All @@ -42,7 +44,8 @@ pub fn traverse_directory(

// ~~~ Build the Tree ~~~
let tree = WalkBuilder::new(&canonical_root_path)
.git_ignore(true)
.hidden(!hidden) // By default hidden=false, so we invert the flag
.git_ignore(!no_ignore) // By default no_ignore=false, so we invert the flag
.follow_links(follow_symlinks)
.build()
.filter_map(|e| e.ok())
Expand Down

0 comments on commit fa72ecd

Please sign in to comment.