Skip to content

feat(cli): Add Global CLI Tool for Local Directory Analysis #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 20, 2024

Conversation

justinlevi
Copy link
Contributor

Description

This PR adds a command-line interface to gitingest, allowing users to analyze local directories without needing to run the web server. The CLI tool can be installed globally and provides similar functionality to the web interface.

Features

  • Global command-line tool installation via pip install -e .
  • Analyze any local directory with gitingest /path/to/directory
  • Configurable output location with -o flag
  • Support for custom file size limits with --max-size
  • Additional ignore patterns via -i flag
  • Maintains compatibility with web app's ingest functionality
  • Automatic file type detection and text content extraction
  • Directory tree visualization
  • File content summary with statistics

Usage Examples

# Basic usage - outputs to <dirname>.txt
gitingest ~/projects/myproject

# Custom output location
gitingest ~/projects/myproject -o ~/Desktop/analysis.txt

# Ignore specific patterns
gitingest ~/projects/myproject -i "*.csv" -i "*.json"

# Set maximum file size (e.g., 5MB)
gitingest ~/projects/myproject -s 5000000

Technical Details

  • Uses Click for CLI argument parsing and help documentation
  • Shares core functionality with web app through ingest.py
  • Maintains same ignore patterns and file type detection
  • Preserves token counting and size limit features

Documentation

  • Added CLI usage section to README.md
  • Included installation instructions
  • Documented all available options
  • Added usage examples

Testing

The CLI has been tested with:

  • Different directory sizes and structures
  • Various file types
  • Custom ignore patterns
  • Different output locations
  • Size limit enforcement

- 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
- Rename analyze_codebase back to ingest_from_query

- Add analyze_codebase as an alias for CLI compatibility

- Remove tokencost import to fix web app startup

- Clean up whitespace and formatting
- Add click-based CLI interface

- Support output file specification

- Add max file size and ignore pattern options

- Match web app query format for compatibility
@cyclotruc
Copy link
Member

Wonderful! very valuable contribution, I'll run my own tests asap, hoping to merge this very soon

Copy link
Member

@cyclotruc cyclotruc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I plan to add github urls compatibility and include patterns but this is a very solid addition to the project, thanks again

@cyclotruc cyclotruc merged commit 728c4af into coderamp-labs:main Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants