forked from cyclotruc/gitingest
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cli): Add Global CLI Tool for Local Directory Analysis (cyclotru…
…c#38) * feat(cli): add comprehensive CLI documentation to README - Add installation instructions for global CLI usage - Document all CLI options and flags with examples - Include detailed usage examples for common scenarios - Describe output format and automatic file ignoring - Maintain consistent formatting with existing README sections
- Loading branch information
1 parent
808bded
commit 728c4af
Showing
6 changed files
with
230 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,5 @@ slowapi | |
tokencost | ||
pytest | ||
pytest-asyncio | ||
pytest-cov | ||
pytest-cov | ||
click>=8.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from setuptools import setup, find_packages | ||
|
||
setup( | ||
name="gitingest", | ||
version="0.1.0", | ||
packages=find_packages(), | ||
include_package_data=True, | ||
install_requires=[ | ||
"click", | ||
], | ||
entry_points={ | ||
"console_scripts": [ | ||
"gitingest=src.cli:main", | ||
], | ||
}, | ||
python_requires=">=3.6", | ||
author="Your Name", | ||
description="A tool to analyze and create text dumps of git repositories", | ||
long_description=open("README.md").read(), | ||
long_description_content_type="text/markdown", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import click | ||
import os | ||
from .ingest import analyze_codebase, DEFAULT_IGNORE_PATTERNS, MAX_FILE_SIZE | ||
|
||
@click.command() | ||
@click.argument('path', type=click.Path(exists=True)) | ||
@click.option('--output', '-o', default=None, help='Output file path (default: <repo_name>.txt in current directory)') | ||
@click.option('--max-size', '-s', default=MAX_FILE_SIZE, help='Maximum file size to process in bytes') | ||
@click.option('--ignore-pattern', '-i', multiple=True, help='Additional patterns to ignore') | ||
def main(path, output, max_size, ignore_pattern): | ||
"""Analyze a directory and create a text dump of its contents.""" | ||
try: | ||
# Convert path to absolute path | ||
abs_path = os.path.abspath(path) | ||
repo_name = os.path.basename(abs_path) | ||
|
||
# Combine default and custom ignore patterns | ||
ignore_patterns = list(DEFAULT_IGNORE_PATTERNS) | ||
if ignore_pattern: | ||
ignore_patterns.extend(ignore_pattern) | ||
|
||
# If no output file specified, use repo name in current directory | ||
if output is None: | ||
output = f"{repo_name}.txt" | ||
|
||
# Create a query dict to match the expected format | ||
query = { | ||
'local_path': abs_path, | ||
'subpath': '/', | ||
'user_name': os.path.basename(os.path.dirname(abs_path)), | ||
'repo_name': repo_name, | ||
'ignore_patterns': ignore_patterns, | ||
'include_patterns': [], | ||
'pattern_type': 'exclude', | ||
'max_file_size': max_size, | ||
'branch': None, | ||
'commit': None, | ||
'type': 'tree', | ||
'slug': repo_name | ||
} | ||
|
||
# Run analysis | ||
summary, tree, content = analyze_codebase(query) | ||
|
||
# Write to file | ||
with open(output, 'w') as f: | ||
f.write(f"Summary:\n{summary}\n\n") | ||
f.write(f"{tree}\n") | ||
f.write(content) | ||
|
||
click.echo(f"Analysis complete! Output written to: {output}") | ||
click.echo("\nSummary:") | ||
click.echo(summary) | ||
|
||
except Exception as e: | ||
click.echo(f"Error: {str(e)}", err=True) | ||
raise click.Abort() | ||
|
||
if __name__ == '__main__': | ||
main() |
Oops, something went wrong.