Skip to content
Prev Previous commit
Next Next commit
docs
  • Loading branch information
filipchristiansen committed Jul 1, 2025
commit 2a49b20436bc4554da9388259bfd952cb2b8caa9
46 changes: 16 additions & 30 deletions src/gitingest/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ class _CLIArgs(TypedDict):

@click.command()
@click.argument("source", type=str, default=".")
@click.option(
"--output",
"-o",
default=None,
help="Output file path (default: digest.txt in current directory). Use '-' for stdout.",
)
@click.option(
"--max-size",
"-s",
Expand Down Expand Up @@ -63,32 +57,23 @@ class _CLIArgs(TypedDict):
"If omitted, the CLI will look for the GITHUB_TOKEN environment variable."
),
)
@click.option(
"--output",
"-o",
default=None,
help="Output file path (default: digest.txt in current directory). Use '-' for stdout.",
)
def main(**cli_kwargs: Unpack[_CLIArgs]) -> None:
"""
Main entry point for the CLI. This function is called when the CLI is run as a script.

It calls the async main function to run the command.
"""Run the CLI entry point to analyze a repo / directory and dump its contents.

Parameters
----------
source : str
A directory path or a Git repository URL.
output : str, optional
The path where the output file will be written. If not specified, the output will be written
to a file named `digest.txt` in the current directory. Use '-' to output to stdout.
max_size : int
Maximum file size (in bytes) to consider.
exclude_pattern : Tuple[str, ...]
Glob patterns for pruning the file set.
include_pattern : Tuple[str, ...]
Glob patterns for including files in the output.
branch : str, optional
Specific branch to ingest (defaults to the repository's default).
include_gitignored : bool
If provided, include files normally ignored by .gitignore.
token: str, optional
GitHub personal-access token (PAT). Needed when *source* refers to a
**private** repository. Can also be set via the ``GITHUB_TOKEN`` env var.
**cli_kwargs : Unpack[_CLIArgs]
A dictionary of keyword arguments forwarded to ``ingest_async``.

Notes
-----
See ``ingest_async`` for a detailed description of each argument.

Examples
--------
Expand All @@ -108,6 +93,7 @@ def main(**cli_kwargs: Unpack[_CLIArgs]) -> None:
Private repositories:
$ gitingest https://github.com/user/private-repo -t ghp_token
$ GITHUB_TOKEN=ghp_token gitingest https://github.com/user/private-repo

"""
asyncio.run(_async_main(**cli_kwargs))

Expand Down Expand Up @@ -147,8 +133,8 @@ async def _async_main(
GitHub personal access token (PAT) for accessing private repositories.
Can also be set via the ``GITHUB_TOKEN`` environment variable.
output : str | None
The path where the output file will be written. If not specified, the output will be written
to a file named `digest.txt` in the current directory. Use '-' to output to stdout.
The path where the output file will be written (default: ``digest.txt`` in current directory).
Use ``"-"`` to write to ``stdout``.

Raises
------
Expand Down