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 @@ +
+ +
+
+
+
+ +
+
+
+
+ +
+ +
+
+
+
+ + +
+
+
+ +
+
+
+
+ + +
+
+
+
+ {% if show_examples %}
@@ -101,4 +147,4 @@
{% endif %} - \ No newline at end of file + diff --git a/src/templates/components/result.jinja b/src/templates/components/result.jinja index 00b6f934..edf25d5c 100644 --- a/src/templates/components/result.jinja +++ b/src/templates/components/result.jinja @@ -64,7 +64,7 @@ class="px-4 py-2 bg-[#ffc480] border-[3px] border-gray-900 text-gray-900 rounded group-hover:-translate-y-px group-hover:-translate-x-px transition-transform relative z-10 flex items-center gap-2"> + d="M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 012-2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3" /> Copy @@ -93,23 +93,24 @@ class="px-4 py-2 bg-[#ffc480] border-[3px] border-gray-900 text-gray-900 rounded group-hover:-translate-y-px group-hover:-translate-x-px transition-transform relative z-10 flex items-center gap-2"> - - Copy - + d="M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 012-2h2a2 2 0 012-2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3" /> + + Copy + + - -
-
+
+
+
+
-
-{% endif %} \ No newline at end of file +{% endif %}