diff --git a/README.md b/README.md index 991aeafe..92338745 100644 --- a/README.md +++ b/README.md @@ -127,4 +127,27 @@ uvicorn main:app --reload The frontend will be available at `localhost:8000` +## 🗂️ Using Local Directories +In addition to GitHub Public repo URLs, you can now use local directories with the CLI and Python package. + +### CLI usage with local directories + +```bash +# Basic usage with local directory +gitingest /path/to/local/directory + +# See more options +gitingest --help +``` + +### Python package usage with local directories + +```python +from gitingest import ingest + +# Ingest from a local directory +summary, tree, content = ingest("/path/to/local/directory") +``` + +By default, this won't write a file but can be enabled with the `output` argument. diff --git a/src/gitingest/ingest.py b/src/gitingest/ingest.py index eac20818..52fbc460 100644 --- a/src/gitingest/ingest.py +++ b/src/gitingest/ingest.py @@ -25,4 +25,7 @@ def ingest(source: str, max_file_size: int = 10 * 1024 * 1024, include_patterns: if query['url']: # Get parent directory two levels up from local_path (../tmp) cleanup_path = str(Path(query['local_path']).parents[1]) - shutil.rmtree(cleanup_path, ignore_errors=True) \ No newline at end of file + shutil.rmtree(cleanup_path, ignore_errors=True) + elif Path(source).is_dir(): + # If the source is a local directory, no need to clean up + pass diff --git a/src/gitingest/ingest_from_query.py b/src/gitingest/ingest_from_query.py index 2991b093..3ffc610e 100644 --- a/src/gitingest/ingest_from_query.py +++ b/src/gitingest/ingest_from_query.py @@ -338,4 +338,3 @@ def ingest_from_query(query: dict) -> Dict: return ingest_single_file(path, query) else: return ingest_directory(path, query) - diff --git a/src/templates/components/github_form.jinja b/src/templates/components/github_form.jinja index ec6054ef..61ec0f31 100644 --- a/src/templates/components/github_form.jinja +++ b/src/templates/components/github_form.jinja @@ -86,6 +86,52 @@ +