This commit is contained in:
297
README.md
297
README.md
@@ -1,206 +1,175 @@
|
||||
# gitignore-generator
|
||||
# Gitignore Generator
|
||||
|
||||
A CLI tool that automatically generates `.gitignore` files based on project type, tech stack, and IDE. It detects project structure, supports multiple languages/frameworks, generates IDE-specific ignores, allows customization via config file, and works offline with a curated collection.
|
||||
A CLI tool that generates optimized `.gitignore` files with support for 50+ frameworks, IDE-specific templates, interactive custom builders, template management, and syntax validation. All processing is done locally with zero network dependencies.
|
||||
|
||||
## Features
|
||||
|
||||
- Auto-detects project type from file structure
|
||||
- Multi-language/framework support (Python, JavaScript, TypeScript, Java, Go, Rust, .NET, PHP, Ruby)
|
||||
- Framework-specific templates (Django, Flask, React, Vue, Angular, Rails, Laravel, Spring)
|
||||
- IDE-specific ignore rules (VS Code, JetBrains, Visual Studio Code)
|
||||
- Operating system-specific ignores (Linux, macOS, Windows)
|
||||
- Tool-specific templates (Docker, Gradle, Maven, Jupyter, Terraform)
|
||||
- Interactive wizard mode for guided generation
|
||||
- Configuration file support for customization
|
||||
- Works completely offline
|
||||
- Append or overwrite existing `.gitignore` files
|
||||
- **50+ Language/Framework Templates** - Python, JavaScript, Java, Go, Rust, C++, C#, Ruby, PHP, TypeScript, Swift, Kotlin, Scala, Dart, and more
|
||||
- **IDE-Specific Templates** - VSCode, JetBrains (IntelliJ, PyCharm), Visual Studio, Vim, Emacs
|
||||
- **Interactive Mode** - Wizard-style interface for building custom .gitignore files
|
||||
- **Template Management** - Add, remove, export custom templates
|
||||
- **Syntax Validation** - Detects common mistakes and potential issues
|
||||
- **Local-First** - All processing done locally, no network dependencies
|
||||
|
||||
## Installation
|
||||
|
||||
### From Source
|
||||
|
||||
```bash
|
||||
pip install -e .
|
||||
```
|
||||
|
||||
### From PyPI
|
||||
|
||||
```bash
|
||||
pip install gitignore-generator
|
||||
```
|
||||
|
||||
Or install from source:
|
||||
|
||||
```bash
|
||||
git clone https://github.com/yourusername/gitignore-generator.git
|
||||
cd gitignore-generator
|
||||
pip install -e .
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### Auto-detect and generate
|
||||
|
||||
Automatically detect your project type and generate a `.gitignore`:
|
||||
### Generate a .gitignore from templates
|
||||
|
||||
```bash
|
||||
gitignore-generator generate
|
||||
```
|
||||
|
||||
### Specify types manually
|
||||
|
||||
Generate for specific types:
|
||||
|
||||
```bash
|
||||
# Single type
|
||||
gitignore-generator generate --language python
|
||||
|
||||
# Multiple types
|
||||
gitignore-generator generate --language python --framework django --ide vscode
|
||||
|
||||
# Using positional arguments
|
||||
gitignore-generator generate python django vscode
|
||||
```
|
||||
|
||||
### Output options
|
||||
|
||||
Write to stdout instead of file:
|
||||
|
||||
```bash
|
||||
gitignore-generator generate python --stdout
|
||||
```
|
||||
|
||||
Specify output file:
|
||||
|
||||
```bash
|
||||
gitignore-generator generate python -o custom.gitignore
|
||||
```
|
||||
|
||||
Overwrite existing file:
|
||||
|
||||
```bash
|
||||
gitignore-generator generate python --overwrite
|
||||
gitignore generate python
|
||||
gitignore generate python javascript
|
||||
gitignore generate python --ide vscode
|
||||
gitignore generate python -o my.gitignore
|
||||
```
|
||||
|
||||
### List available templates
|
||||
|
||||
```bash
|
||||
# List all templates
|
||||
gitignore-generator list
|
||||
|
||||
# List by category
|
||||
gitignore-generator list --category language
|
||||
gitignore-generator list --category framework
|
||||
gitignore-generator list --category ide
|
||||
gitignore-generator list --category os
|
||||
gitignore-generator list --category tools
|
||||
gitignore list
|
||||
gitignore list --category languages
|
||||
gitignore list --category ides
|
||||
```
|
||||
|
||||
### Detect project type
|
||||
### Search for templates
|
||||
|
||||
```bash
|
||||
gitignore-generator detect
|
||||
gitignore search python
|
||||
gitignore search java
|
||||
```
|
||||
|
||||
### Interactive wizard
|
||||
|
||||
Run an interactive wizard for guided generation:
|
||||
### Interactive Mode
|
||||
|
||||
```bash
|
||||
gitignore-generator wizard
|
||||
gitignore interactive
|
||||
```
|
||||
|
||||
### Use configuration file
|
||||
|
||||
Specify a configuration file:
|
||||
### Validate existing .gitignore
|
||||
|
||||
```bash
|
||||
gitignore-generator --config .gitignorerc generate
|
||||
gitignore validate .gitignore
|
||||
```
|
||||
|
||||
### Template Management
|
||||
|
||||
```bash
|
||||
# Add custom template
|
||||
gitignore template-add my_template template_file.gitignore
|
||||
|
||||
# Remove custom template
|
||||
gitignore template-remove my_template
|
||||
|
||||
# Export template to file
|
||||
gitignore template-export python exported.gitignore
|
||||
|
||||
# Get template info
|
||||
gitignore info python
|
||||
```
|
||||
|
||||
## Commands
|
||||
|
||||
| Command | Description |
|
||||
|---------|-------------|
|
||||
| `generate [TEMPLATES...]` | Generate .gitignore from templates |
|
||||
| `list` | List available templates |
|
||||
| `search QUERY` | Search for templates |
|
||||
| `interactive` | Launch interactive wizard |
|
||||
| `validate FILE` | Validate .gitignore syntax |
|
||||
| `template-add NAME FILE` | Add custom template |
|
||||
| `template-remove NAME` | Remove custom template |
|
||||
| `template-export NAME FILE` | Export template to file |
|
||||
| `info TEMPLATE` | Show template information |
|
||||
|
||||
## Templates
|
||||
|
||||
### Languages & Frameworks
|
||||
|
||||
- Python, JavaScript, Java, Go, Rust
|
||||
- C++, C#, TypeScript, PHP, Ruby
|
||||
- Swift, Kotlin, Scala, Dart
|
||||
- Haskell, Elixir, Clojure, OCaml
|
||||
- Perl, Lua, R
|
||||
- .NET, Terraform, Ansible
|
||||
- Docker, Kubernetes
|
||||
|
||||
### IDEs
|
||||
|
||||
- VSCode, JetBrains (IntelliJ, PyCharm, etc.)
|
||||
- Visual Studio, Vim, Emacs
|
||||
|
||||
## Interactive Mode
|
||||
|
||||
The interactive mode guides you through creating a `.gitignore`:
|
||||
|
||||
1. Select a category (Languages, IDEs, or Custom)
|
||||
2. Choose templates from the list
|
||||
3. Add custom patterns
|
||||
4. Preview and edit the result
|
||||
5. Save to file
|
||||
|
||||
## Template Management
|
||||
|
||||
Custom templates are stored in `~/.config/gitignore-generator/templates/`.
|
||||
|
||||
### Environment Variables
|
||||
|
||||
| Variable | Description | Default |
|
||||
|----------|-------------|---------|
|
||||
| `GITIGNORE_DEFAULT_FILE` | Default output file | `.gitignore` |
|
||||
| `TEMPLATE_DIR` | Template directory | `templates` |
|
||||
|
||||
## Examples
|
||||
|
||||
### Python project with VSCode
|
||||
|
||||
```bash
|
||||
gitignore generate python --ide vscode
|
||||
```
|
||||
|
||||
### Full stack project
|
||||
|
||||
```bash
|
||||
gitignore generate python javascript --ide jetbrains
|
||||
```
|
||||
|
||||
### With custom output
|
||||
|
||||
```bash
|
||||
gitignore generate .gitignore - java kotlin -of
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
Create a `.gitignorerc` file in your project root or home directory:
|
||||
Create a `.gitignore-generator/config.yaml`:
|
||||
|
||||
```yaml
|
||||
custom_templates:
|
||||
my_template: |
|
||||
# Custom template content
|
||||
*.custom
|
||||
.custom/
|
||||
|
||||
default_types:
|
||||
- python
|
||||
- vscode
|
||||
|
||||
exclude_patterns:
|
||||
- "*.pyc"
|
||||
|
||||
include_patterns:
|
||||
python:
|
||||
- "src/"
|
||||
template_dir: templates
|
||||
default_output: .gitignore
|
||||
custom_templates_dir: ~/.config/gitignore-generator/templates
|
||||
```
|
||||
|
||||
## Available Templates
|
||||
|
||||
### Languages
|
||||
- Python
|
||||
- JavaScript
|
||||
- TypeScript
|
||||
- Java
|
||||
- Go
|
||||
- Rust
|
||||
- .NET
|
||||
- PHP
|
||||
- Ruby
|
||||
|
||||
### Frameworks
|
||||
- Django
|
||||
- Flask
|
||||
- React
|
||||
- Vue
|
||||
- Angular
|
||||
- Ruby on Rails
|
||||
- Laravel
|
||||
- Spring
|
||||
|
||||
### IDEs
|
||||
- VS Code
|
||||
- JetBrains
|
||||
- Visual Studio Code
|
||||
|
||||
### Operating Systems
|
||||
- Linux
|
||||
- macOS
|
||||
- Windows
|
||||
|
||||
### Tools
|
||||
- Docker
|
||||
- Gradle
|
||||
- Maven
|
||||
- Jupyter
|
||||
- Terraform
|
||||
|
||||
## Development
|
||||
|
||||
### Setup
|
||||
|
||||
```bash
|
||||
git clone https://github.com/yourusername/gitignore-generator.git
|
||||
cd gitignore-generator
|
||||
pip install -e ".[dev]"
|
||||
```
|
||||
|
||||
### Running Tests
|
||||
|
||||
```bash
|
||||
pytest tests/ -v
|
||||
pytest tests/ --cov=src
|
||||
```
|
||||
|
||||
### Adding New Templates
|
||||
|
||||
1. Create a new `.gitignore` file in the appropriate category directory under `src/templates/`
|
||||
2. Add the template to the `TEMPLATE_MAP` in `src/generator.py`
|
||||
3. Add detection patterns to `src/detector.py` if applicable
|
||||
4. Add tests in the appropriate test file
|
||||
|
||||
## License
|
||||
|
||||
MIT License - see [LICENSE](LICENSE) file for details.
|
||||
|
||||
## Contributing
|
||||
|
||||
Contributions are welcome! Please feel free to submit a Pull Request.
|
||||
1. Fork the repository
|
||||
2. Create a feature branch
|
||||
3. Add your template to `templates/languages/` or `templates/ides/`
|
||||
4. Update `templates/templates.json`
|
||||
5. Run tests: `pytest tests/ -v`
|
||||
6. Submit a pull request
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
|
||||
Reference in New Issue
Block a user