Skip to content

Commit fdcbc53

Browse files
authored
docs: Fix CLI help text accuracy (#332)
* docs: Fix CLI help text accuracy - Add stdout documentation to --output option help text - Update default filename to 'digest.txt' consistently - Enhance docstrings with comprehensive usage examples - Improve GitHub token documentation with environment variable support - Fix inconsistencies between help text and actual CLI behavior Co-authored-by: Filip Christiansen
1 parent e669e44 commit fdcbc53

File tree

3 files changed

+41
-10
lines changed

3 files changed

+41
-10
lines changed

src/gitingest/cli.py

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,40 @@ class _CLIArgs(TypedDict):
6161
"--output",
6262
"-o",
6363
default=None,
64-
help="Write to PATH (or '-' for stdout, default: <repo>.txt).",
64+
help="Output file path (default: digest.txt in current directory). Use '-' for stdout.",
6565
)
6666
def main(**cli_kwargs: Unpack[_CLIArgs]) -> None:
67-
"""Run the CLI entry point to analyze a repo / directory and dump its contents."""
67+
"""Run the CLI entry point to analyze a repo / directory and dump its contents.
68+
69+
Parameters
70+
----------
71+
**cli_kwargs : Unpack[_CLIArgs]
72+
A dictionary of keyword arguments forwarded to ``ingest_async``.
73+
74+
Notes
75+
-----
76+
See ``ingest_async`` for a detailed description of each argument.
77+
78+
Examples
79+
--------
80+
Basic usage:
81+
$ gitingest
82+
$ gitingest /path/to/repo
83+
$ gitingest https://github.com/user/repo
84+
85+
Output to stdout:
86+
$ gitingest -o -
87+
$ gitingest https://github.com/user/repo --output -
88+
89+
With filtering:
90+
$ gitingest -i "*.py" -e "*.log"
91+
$ gitingest --include-pattern "*.js" --exclude-pattern "node_modules/*"
92+
93+
Private repositories:
94+
$ gitingest https://github.com/user/private-repo -t ghp_token
95+
$ GITHUB_TOKEN=ghp_token gitingest https://github.com/user/private-repo
96+
97+
"""
6898
asyncio.run(_async_main(**cli_kwargs))
6999

70100

@@ -88,7 +118,7 @@ async def _async_main(
88118
Parameters
89119
----------
90120
source : str
91-
Directory path or Git repository URL.
121+
A directory path or a Git repository URL.
92122
max_size : int
93123
Maximum file size in bytes to ingest (default: 10 MB).
94124
exclude_pattern : tuple[str, ...] | None
@@ -103,7 +133,7 @@ async def _async_main(
103133
GitHub personal access token (PAT) for accessing private repositories.
104134
Can also be set via the ``GITHUB_TOKEN`` environment variable.
105135
output : str | None
106-
Destination file path. If ``None``, the output is written to ``<repo_name>.txt`` in the current directory.
136+
The path where the output file will be written (default: ``digest.txt`` in current directory).
107137
Use ``"-"`` to write to ``stdout``.
108138
109139
Raises

src/gitingest/utils/git_utils.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ async def check_repo_exists(url: str, token: str | None = None) -> bool:
102102
If the curl command returns an unexpected status code.
103103
104104
"""
105-
expected_path_length = 2
106105
if token and is_github_host(url):
107106
return await _check_github_repo_exists(url, token=token)
108107

@@ -121,11 +120,13 @@ async def check_repo_exists(url: str, token: str | None = None) -> bool:
121120
response = stdout.decode()
122121
status_line = response.splitlines()[0].strip()
123122
parts = status_line.split(" ")
123+
124+
expected_path_length = 2
124125
if len(parts) >= expected_path_length:
125-
status_code_str = parts[1]
126-
if status_code_str in ("200", "301"):
126+
status = parts[1]
127+
if status in ("200", "301"):
127128
return True
128-
if status_code_str in ("302", "404"):
129+
if status in ("302", "404"):
129130
return False
130131
msg = f"Unexpected status line: {status_line}"
131132
raise RuntimeError(msg)

src/static/llm.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,20 +176,20 @@ gitingest https://github.com/user/private-repo -t $GITHUB_TOKEN -o -
176176
# Specific branch analysis (short flag)
177177
gitingest https://github.com/user/repo -b main -o -
178178

179-
# Save to file (default: <repo_name>.txt in current directory)
179+
# Save to file (default: digest.txt in current directory)
180180
gitingest https://github.com/user/repo -o my_analysis.txt
181181

182182
# Ultra-concise example for small files only
183183
gitingest https://github.com/user/repo -i "*.py" -s 51200 -o -
184184
```
185185

186186
**Key Parameters for AI Agents**:
187-
- `-o` / `--output`: Stream to STDOUT with `-` (default saves to `<repo_name>.txt`)
188187
- `-s` / `--max-size`: Maximum file size in bytes to process (default: no limit)
189188
- `-i` / `--include-pattern`: Include files matching Unix shell-style wildcards
190189
- `-e` / `--exclude-pattern`: Exclude files matching Unix shell-style wildcards
191190
- `-b` / `--branch`: Specify branch to analyze (defaults to repository's default branch)
192191
- `-t` / `--token`: GitHub personal access token for private repositories
192+
- `-o` / `--output`: Stream to STDOUT with `-` (default saves to `digest.txt`)
193193

194194
### 4.2 Python Package (Best for Code Integration)
195195
```python

0 commit comments

Comments
 (0)