Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Contributing to Rstring

Thanks for your interest in contributing! Here's how to get started:

## Development Setup

1. **Clone and setup development environment**:
```bash
git clone https://github.com/tnunamak/rstring.git
cd rstring
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
```

2. **Install for development**:
```bash
pip install -e .
pip install -r requirements-dev.txt
```

3. **Run tests**:
```bash
pytest
```

4. **Use development version**:
```bash
# With dev environment activated
rstring [options] # Uses your development code
```

5. **Switch between versions**:
```bash
# Use development version
source venv/bin/activate
rstring [options]

# Use production version
deactivate
rstring [options] # Uses globally installed version
```

## Guidelines

- Fork the repo and create your branch from `main`
- Add tests for new functionality
- Ensure all tests pass
- Keep the focused scope: efficient code stringification for AI assistants
- Follow existing code style

## Questions?

Open an issue for discussion before major changes.
93 changes: 76 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,24 @@ For more detailed information about pipx and its usage, refer to the [pipx docum

Basic usage:
```bash
rstring # Use the default preset
rstring # All files (filtered by .gitignore)
```

Work with different directories:
```bash
rstring --include=*/ --include=*.py --exclude=* # traverse all dirs, include .py files, exclude everything else
rstring /path/to/project # Analyze a specific directory
rstring -C /path/to/project # Change directory before processing
```

Get help:
Custom filtering:
```bash
rstring --help
rstring --include='*.py' # Only Python files
rstring --include='*/' --include='*.js' --exclude='test*' # Complex patterns
```

Use a specific preset:
Get help:
```bash
rstring --preset my_preset
rstring --help
```

Get a tree view of selected files:
Expand All @@ -75,12 +78,44 @@ rstring --summary

## Advanced Usage

### Custom Presets
### Custom Filtering

Rstring uses rsync's powerful include/exclude patterns:

Create a new preset:
```bash
rstring --save-preset python --include=*/ --include=*.py --exclude=* # save it
rstring --preset python # use it
# Include only Python files
rstring --include='*/' --include='*.py' --exclude='*'

# Include web development files, exclude tests
rstring --include='*/' --include='*.{js,css,html}' --exclude='test*' --exclude='*'

# Include documentation
rstring --include='*/' --include='*.md' --include='*.rst' --exclude='*'
```

### Creating Custom Shortcuts

For frequently used patterns, create shell aliases in your `.bashrc` or `.zshrc`:

```bash
# Python source files only
alias rstring-py="rstring --include='*/' --include='*.py' --exclude='test*'"

# Web development files
alias rstring-web="rstring --include='*/' --include='*.{js,ts,css,html}' --exclude='node_modules/'"

# Documentation files
alias rstring-docs="rstring --include='*/' --include='*.{md,rst,txt}' --exclude='*'"

# All source code (no tests, docs, or config)
alias rstring-src="rstring --include='src/' --include='lib/' --exclude='*'"
```

Usage:
```bash
rstring-py # Python files in current directory
rstring-web -C /path/to/app # Web files in different directory
rstring-docs --summary # Documentation with tree view
```

### File Preview
Expand All @@ -90,15 +125,14 @@ Limit output to first N lines of each file:
rstring --preview-length=10
```


### Gitignore Integration

By default, Rstring automatically excludes .gitignore patterns. To ignore .gitignore:
```bash
rstring --no-gitignore
```

### Interactive mode:
### Interactive mode

Enter interactive mode to continuously preview and select matched files:
```bash
Expand All @@ -109,7 +143,7 @@ rstring -i

1. **Under the Hood**: Rstring efficiently selects files based on filters by running `rsync --archive --itemize-changes --dry-run --list-only <your filters>`. This means you can use Rsync's powerful include/exclude patterns to customize file selection.

2. **Preset System**: The default configuration file is at `~/.rstring.yaml`. The 'common' preset is used by default and includes sensible exclusions for most projects.
2. **Default Behavior**: When run without specific patterns, rstring includes all files and directories, filtered by your project's `.gitignore` file.

3. **Output Format**:
```
Expand All @@ -128,20 +162,45 @@ rstring -i

## Pro Tips

1. **Explore the default preset**: Check `~/.rstring.yaml` to see how the 'common' preset works.
1. **Start simple**: `rstring` with no arguments gives you everything in your project (filtered by .gitignore).

2. **Refer to Rsync documentation**: Rstring uses Rsync for file selection. Refer to the [Filter Rules](https://linux.die.net/man/1/rsync) section of the rsync man page to understand how include/exclude patterns work.

3. **Customize for your project**: Create a project-specific preset for quick context gathering.
3. **Create project-specific aliases**: Set up shell aliases for your common file selection patterns.

4. **Use with AI tools**: Rstring is great for preparing code context for AI programming assistants.

5. **Large projects may produce substantial output**: Use `--preview-length` or specific patterns for better manageability.

## Common Patterns

Here are some useful rsync patterns for different scenarios:

```bash
# Python projects
rstring --include='*/' --include='*.py' --exclude='__pycache__/' --exclude='test*'

# JavaScript/Node.js projects
rstring --include='*/' --include='*.{js,ts,jsx,tsx}' --exclude='node_modules/' --exclude='test*'

# Web projects (frontend)
rstring --include='*/' --include='*.{js,ts,css,html,vue,svelte}' --exclude='dist/' --exclude='build/'

# Documentation only
rstring --include='*/' --include='*.{md,rst,txt}' --exclude='*'

# Configuration files
rstring --include='*/' --include='*.{json,yaml,yml,toml,ini}' --exclude='*'

# Source code only (exclude tests, docs, config)
rstring --include='src/' --include='lib/' --exclude='*'
```

## Support and Contributing

- Issues and feature requests: [GitHub Issues](https://github.com/tnunamak/rstring/issues)
- Contributions: Pull requests are welcome!
- **Issues and feature requests**: [GitHub Issues](https://github.com/tnunamak/rstring/issues)
- **Contributing**: See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup and guidelines
- **Pull requests welcome!**

## License

Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
pytest==8.3.2
hypothesis==6.108.5
Loading