From 3c1a225ccc6ef332949340ebcab27e31b49119e0 Mon Sep 17 00:00:00 2001 From: Daniel Henry Date: Mon, 26 Jan 2026 16:26:56 -0600 Subject: [PATCH] Add manual ignore flag Signed-off-by: Daniel Henry --- README.md | 3 ++- dumpy.py | 22 ++++++++++++++++++---- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index c259df9..75df2c0 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ uv tool uninstall dumpy # Usage ``` -usage: dumpy.py [-h] [--no-gitignore] [--include-git-dir] [--no-clipboard] [--no-stats] +usage: dumpy.py [-h] [--no-gitignore] [--include-git-dir] [--no-clipboard] [--no-stats] [--ignore IGNORE] Dumpy: A tool for providing a text representation of a project formatted in a way that LLMs will understand. @@ -33,6 +33,7 @@ options: --include-git-dir Include the .git directory in the output --no-clipboard Skip putting content into the clipboard and ouput directly to the console --no-stats Skip printing stats at the end of the output + --ignore IGNORE Comma separated list of patterns to ignore. ``` # Notes diff --git a/dumpy.py b/dumpy.py index 6faa2fa..dacdd41 100644 --- a/dumpy.py +++ b/dumpy.py @@ -31,8 +31,12 @@ def get_ignore_spec(root: Path): return pathspec.PathSpec.from_lines('gitwildmatch', f) return None -def should_include(path: Path, spec: pathspec.PathSpec | None, root: Path, include_git_dir: bool = False): +def should_include(path: Path, spec: pathspec.PathSpec | None, root: Path, include_git_dir: bool = False, manual_ignores = []): relative_path = path.relative_to(root) + + if any(part in manual_ignores for part in path.parts): + return False + if ".git" in path.parts and not include_git_dir: return False @@ -41,7 +45,7 @@ def should_include(path: Path, spec: pathspec.PathSpec | None, root: Path, inclu return not spec.match_file(str(relative_path)) -def walk_filesystem(ignore_gitignore: bool, include_git_dir: bool = False) -> tuple[int, list[str]]: +def walk_filesystem(ignore_gitignore: bool, include_git_dir: bool = False, manual_ignores = []) -> tuple[int, list[str]]: root = Path(".") spec = None @@ -54,7 +58,7 @@ def walk_filesystem(ignore_gitignore: bool, include_git_dir: bool = False) -> tu for path in root.rglob("*"): if path.is_file(): # print the filename (for now) - if should_include(path, spec, root, include_git_dir): + if should_include(path, spec, root, include_git_dir, manual_ignores): final_content += generate_metadata_string(path, root) file_count += 1 success, content = get_file_contents(path) @@ -100,12 +104,22 @@ def main(): help="Skip printing stats at the end of the output" ) + parser.add_argument( + "--ignore", + type=str, + help="Comma separated list of patterns to ignore." + ) + args = parser.parse_args() content: list[str] = [] content.append(f"Root Directory: {Path(".").absolute()}\n") - count, content = walk_filesystem(ignore_gitignore=args.no_gitignore) + manual_ignores = [] + if args.ignore: + manual_ignores = [item.strip() for item in args.ignore.split(",")] + + count, content = walk_filesystem(ignore_gitignore=args.no_gitignore, manual_ignores=manual_ignores) string_content = "\n".join(content) if args.no_clipboard: print(string_content)