bug
A Rust library for streamlined bug reporting that generates GitHub issue URLs with pre-filled templates. When bugs occur, bug
prints tracing-style error messages to stderr and provides clean GitHub URLs for easy bug reporting.
โจ Features
- ๐ฏ Template-based bug reporting - Define reusable issue templates with named parameters
- ๐ File-based templates - Load templates from markdown files using
include_str!
macro - ๐ท๏ธ Label support - Automatically apply labels to GitHub issues
- โ Parameter validation - Ensures all template placeholders are properly filled at compile time
- ๐ URL encoding - Handles special characters in URLs automatically
- ๐ Multiple templates - Support for different issue types per project
๐ฆ Installation
Add this to your Cargo.toml
:
[]
= "0.1.0"
๐ Quick Start
use ;
This outputs:
๐ BUG ENCOUNTERED in src/main.rs:15
Template: crash
Parameters:
error_type: NullPointerException
function: calculate_sum
line: 42
File a bug report: https://github.com/username/repository/issues/new?title=Application%20Crash%3A%20NullPointerException&body=...
๐ Template Files
Create structured markdown templates for consistent bug reports:
templates/crash_report.md:
Application Crash: {error_type}
- ---
1. 2.3.
{expected_behavior}
{additional_info}
The application crashed with error: {error_type}
Load in Rust:
use ;
๐ฏ Usage Examples
Multiple Template Types
use ;
Comprehensive Bug Reports
// Performance issue reporting
let url = bug!;
// Simple usage without parameters
bug!;
๐ Output Format
The bug!()
macro prints structured information to stderr:
๐ BUG ENCOUNTERED in src/database.rs:127
Template: performance
Parameters:
operation: database_query
expected: 100
actual: 1500
ratio: 15
os: windows
version: 0.1.0
File a bug report: https://github.com/myorg/myproject/issues/new?title=Performance%20Issue...
๐ Terminal Hyperlinks & Clean URLs
Generated GitHub URLs can be quite long (800+ characters) due to URL-encoded template content, making log messages verbose and cluttering terminal output. Terminal hyperlink support using ANSI escape sequences to display clean, clickable text while hiding the long URL underneath.
๐ฑ๏ธ Hyperlink Modes
Configure how links are displayed:
use ;
// Auto-detect terminal hyperlink support (default)
init
.hyperlinks
.build?;
// Always use hyperlinks
init
.hyperlinks
.build?;
// Never use hyperlinks (show full URLs)
init
.hyperlinks
.build?;
๐บ Supported Terminals
Automatic detection works with:
- Windows Terminal
- iTerm2 (macOS)
- WezTerm
- Alacritty
- VS Code Integrated Terminal
- Most xterm-compatible terminals
๐ Output Comparison
With Hyperlinks (clean):
๐ BUG ENCOUNTERED in src/main.rs:45
Template: crash
Parameters:
error_type: NullPointerException
function: calculate_sum
File a bug report
Without Hyperlinks (traditional):
๐ BUG ENCOUNTERED in src/main.rs:45
Template: crash
Parameters:
error_type: NullPointerException
function: calculate_sum
File a bug report: https://github.com/user/repo/issues/new?title=Application%20Crash...
The hyperlink text "File a bug report" becomes clickable and opens the full GitHub issue URL when clicked, keeping your logs clean while maintaining full functionality.
๐ API Reference
Core Functions
init(owner, repo)
- Initialize bug reporting configurationbug!(template, {params})
- Report a bug with given template and parameterscreate_terminal_hyperlink(url, text)
- Create ANSI hyperlink escape sequencesupports_hyperlinks()
- Detect terminal hyperlink support
Structs
IssueTemplate
- Represents a GitHub issue templateTemplateFile
- File-based template with validationBugReportConfigBuilder
- Fluent API for configurationHyperlinkMode
- Configure hyperlink display behavior
Enums
HyperlinkMode::Auto
- Auto-detect terminal support (default)HyperlinkMode::Always
- Always use hyperlinksHyperlinkMode::Never
- Always show full URLs
Macros
template_file!(path, labels: [...])
- Load template from filebug!(template, {key = value, ...})
- Report bug with parameters
๐งช Examples
See the examples/
directory for complete working examples:
template_file_usage.rs
- File-based templates- Template files in
templates/
directory
Run examples:
๐ค Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.