Skip to content

Commit 2678784

Browse files
committed
fix: update default output filename in CLI to 'digest.txt' and improve pattern handling in query parser
1 parent c6eb837 commit 2678784

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/gitingest/cli.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
@click.command()
1515
@click.argument("source", type=str, default=".")
16-
@click.option("--output", "-o", default=None, help="Output file path (default: <repo_name>.txt in current directory)")
16+
@click.option("--output", "-o", default=None, help="Output file path (default: digest.txt)")
1717
@click.option("--max-size", "-s", default=MAX_FILE_SIZE, help="Maximum file size to process in bytes")
1818
@click.option("--exclude-pattern", "-e", multiple=True, help="Patterns to exclude (space-separated patterns allowed)")
1919
@click.option("--include-pattern", "-i", multiple=True, help="Patterns to include (space-separated patterns allowed)")
@@ -37,7 +37,7 @@ def main(
3737
The source directory or repository to analyze.
3838
output : str | None
3939
The path where the output file will be written. If not specified, the output
40-
will be written to a file named `<repo_name>.txt` in the current directory.
40+
will be written to a file named `digest.txt` in the current directory.
4141
max_size : int
4242
The maximum file size to process, in bytes. Files larger than this size will be ignored.
4343
exclude_pattern : tuple[str, ...]
@@ -74,7 +74,7 @@ async def async_main(
7474
The source directory or repository to analyze.
7575
output : str | None
7676
The path where the output file will be written. If not specified, the output
77-
will be written to a file named `<repo_name>.txt` in the current directory.
77+
will be written to a file named `digest.txt` in the current directory.
7878
max_size : int
7979
The maximum file size to process, in bytes. Files larger than this size will be ignored.
8080
exclude_pattern : tuple[str, ...]
@@ -92,12 +92,9 @@ async def async_main(
9292
If there is an error during the execution of the command, this exception is raised to abort the process.
9393
"""
9494
try:
95-
# Get repository name from source path
96-
repo_name = Path(source).name or "repository"
97-
9895
# Set default output filename if not provided
9996
if not output:
100-
output = f"{repo_name}.txt"
97+
output = "digest.txt"
10198

10299
# Parse command line patterns
103100
exclude_patterns = _parse_patterns(exclude_pattern)

src/gitingest/query_parser.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@ async def parse_query(
105105
A dataclass object containing the parsed details of the repository or file path.
106106
"""
107107

108+
# Convert string patterns to set if necessary
109+
if isinstance(ignore_patterns, str):
110+
ignore_patterns = {ignore_patterns} if ignore_patterns else None
111+
if isinstance(include_patterns, str):
112+
include_patterns = {include_patterns} if include_patterns else None
113+
108114
# Determine the parsing method based on the source type
109115
if from_web or urlparse(source).scheme in ("https", "http") or any(h in source for h in KNOWN_GIT_HOSTS):
110116
# We either have a full URL or a domain-less slug

0 commit comments

Comments
 (0)