4cec6ee6939e40c4bf090f81fe4d4b0ffee6716c
gitignore-generator-cli
A CLI tool that generates .gitignore files by specifying technologies/frameworks. Supports 100+ frameworks via gitignore.io integration with offline caching.
Features
- Generate .gitignore - Combine patterns from multiple tech stacks
- Auto-detect - Scan project files and suggest appropriate tech stacks
- Preview mode - Preview generated content before writing
- Offline caching - Fast access to patterns with configurable cache expiration
- Custom patterns - Add your own patterns to generated output
- 100+ frameworks - Full support via gitignore.io API
Installation
From PyPI
pip install gitignore-generator-cli
From Source
git clone https://7000pct.gitea.bloupla.net/7000pctAUTO/gitignore-generator-cli.git
cd gitignore-generator-cli
pip install -e .
Quick Start
Generate .gitignore for specific technologies
# Generate for Node.js and Python
gitignore-generator generate node python
# Generate and save to .gitignore
gitignore-generator generate node python -o .gitignore
# Preview without writing
gitignore-generator generate node python --preview
Auto-detect project type
# Detect and suggest
gitignore-generator detect
# Detect and generate
gitignore-generator detect --preview
gitignore-generator detect -o .gitignore
List supported technologies
# List all
gitignore-generator list
# Filter by name
gitignore-generator list python
Show patterns for a technology
gitignore-generator show node
Commands
generate
Generate .gitignore for specified tech stacks.
gitignore-generator generate [OPTIONS] TECH...
Options:
-o, --output PATH Output file path (default: stdout)
--preview Preview without writing
--add-pattern TEXT Add custom pattern (can be used multiple times)
--force-refresh Force refresh from API, bypass cache
--merge Merge with existing .gitignore
Examples:
gitignore-generator generate node python django
gitignore-generator generate node -o .gitignore --preview
gitignore-generator generate node --add-pattern "*.log"
detect
Auto-detect project type from existing files.
gitignore-generator detect [OPTIONS]
Options:
-o, --output PATH Output file path
--preview Preview without writing
--force-refresh Force refresh from API
list
List all supported tech stacks.
gitignore-generator list [OPTIONS] [SEARCH]
Options:
--force-refresh Force refresh from API
show
Show gitignore patterns for a specific tech.
gitignore-generator show [OPTIONS] TECH
Options:
--force-refresh Force refresh from API
cache
Manage cache.
gitignore-generator cache
clear-cache
Clear all cached patterns.
gitignore-generator clear-cache
cleanup
Remove expired cache entries.
gitignore-generator cleanup --days 7
Configuration
Cache Location
Default: ~/.cache/gitignore-generator/
Customize via:
gitignore-generator --cache-dir /path/to/cache generate node
Custom Patterns
Create a file with custom patterns (one per line):
# ~/.config/gitignore-generator/custom_patterns.txt
*.custom
custom/
.env.local
Supported Technologies
The tool supports 100+ technologies including:
- Languages: Python, Node.js, Go, Rust, Java, C++, Ruby, PHP, Swift, Kotlin
- Frameworks: Django, Flask, Rails, React, Vue, Angular, Express, Spring
- Tools: Docker, Kubernetes, Terraform, Ansible, Git, Vim, Emacs
- IDEs: VS Code, JetBrains, Eclipse, Vim, Emacs
- OS: macOS, Windows, Linux
For full list:
gitignore-generator list
Error Handling
Network Errors
If the API is unavailable, the tool will:
- Use cached patterns if available
- Fall back to local templates
- Show a warning message
Unknown Technology
If you specify an unknown technology, the tool will:
- Show available similar technologies
- Suggest correct names
- Fail with helpful error message
File Permissions
If writing fails due to permissions, the tool will:
- Show error with file path
- Suggest using
--outputwith writable location
Development
Setup
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -e ".[dev]"
# Run tests
pytest tests/ -v --cov=gitignore_generator
Project Structure
gitignore-generator-cli/
├── gitignore_generator/
│ ├── __init__.py # Package marker, version
│ ├── api.py # gitignore.io API client
│ ├── cache.py # Caching system
│ ├── detector.py # Project type detection
│ ├── generator.py # Pattern combination
│ └── cli.py # CLI interface
├── templates/ # Local fallback templates
├── tests/
│ ├── conftest.py # Test fixtures
│ ├── test_api.py # API tests
│ ├── test_cache.py # Cache tests
│ ├── test_detector.py # Detector tests
│ ├── test_generator.py # Generator tests
│ └── test_cli.py # CLI tests
├── pyproject.toml # Project configuration
├── setup.py # Package setup
└── README.md # Documentation
License
MIT License - see LICENSE file for details.
Releases
1
Languages
Python
100%