Thank you for considering contributing to MayR Labs CLI! This document outlines the process and guidelines for contributing.
- Code of Conduct
- Getting Started
- Development Setup
- How to Contribute
- Coding Guidelines
- Testing
- Submitting Changes
This project adheres to a code of conduct. By participating, you are expected to uphold this code. Please be respectful and constructive in all interactions.
- Fork the repository
- Clone your fork:
git clone https://github.com/YOUR_USERNAME/mayrlabs-go.git - Add upstream remote:
git remote add upstream https://github.com/MayR-Labs/mayrlabs-go.git - Create a new branch:
git checkout -b feature/your-feature-name
- Go 1.17 or higher
- Git
cd mayrlabs-go
go mod downloadgo build -o mayrlabs main.gogo test ./... -v- Check if the bug has already been reported in Issues
- If not, create a new issue with:
- Clear title and description
- Steps to reproduce
- Expected vs actual behavior
- Your environment (OS, Go version, etc.)
- Open an issue with the "enhancement" label
- Clearly describe the feature and its use case
- Explain why this feature would be useful
- Find or create an issue for what you want to work on
- Comment on the issue to let others know you're working on it
- Write your code following our coding guidelines
- Add tests for any new functionality
- Update documentation if needed
- Submit a pull request
- Follow standard Go conventions and idioms
- Run
gofmton your code before committing - Use meaningful variable and function names
- Add comments for exported functions and complex logic
- Keep functions small and focused
.
├── cmd/ # CLI commands (Cobra setup)
├── internal/
│ ├── commands/ # Command implementations
│ ├── utils/ # Utility functions
│ └── config/ # Configuration handling
├── tests/ # Integration tests
└── main.go # Application entry point
- Create a new file in
internal/commands/(e.g.,mycommand.go) - Implement your command using Cobra:
package commands
import (
"github.com/spf13/cobra"
)
var MyCmd = &cobra.Command{
Use: "mycommand",
Short: "Brief description",
Long: "Detailed description",
RunE: func(cmd *cobra.Command, args []string) error {
// Implementation
return nil
},
}- Add the command to
cmd/root.go:
func init() {
rootCmd.AddCommand(commands.MyCmd)
}- Write tests in
internal/commands/mycommand_test.go
- Always handle errors explicitly
- Return errors rather than panicking
- Use
fmt.Errorfwith%wfor error wrapping
- Write unit tests for all new functionality
- Aim for >80% code coverage
- Use table-driven tests where appropriate
- Test edge cases and error scenarios
Example:
func TestMyFunction(t *testing.T) {
tests := []struct {
name string
input string
want string
wantErr bool
}{
// Test cases
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := MyFunction(tt.input)
if (err != nil) != tt.wantErr {
t.Errorf("MyFunction() error = %v, wantErr %v", err, tt.wantErr)
return
}
if got != tt.want {
t.Errorf("MyFunction() = %v, want %v", got, tt.want)
}
})
}
}- Code follows project style guidelines
- All tests pass:
go test ./... - Code passes linting:
go vet ./... - Added/updated tests for changes
- Updated documentation if needed
- Commit messages are clear and descriptive
-
Update your branch with the latest upstream:
git fetch upstream git rebase upstream/main
-
Push your changes:
git push origin feature/your-feature-name
-
Create a Pull Request:
- Use a clear, descriptive title
- Reference any related issues
- Describe what changes you made and why
- Include screenshots for UI changes (if applicable)
-
Address review feedback:
- Make requested changes
- Push updates to the same branch
- Respond to comments
- Use the present tense ("Add feature" not "Added feature")
- Use the imperative mood ("Move cursor to..." not "Moves cursor to...")
- Limit the first line to 72 characters
- Reference issues and pull requests when relevant
Example:
Add support for generating TypeScript config
- Implement TypeScript configuration generation
- Add tests for TypeScript config
- Update documentation
Fixes #123
If you have questions, feel free to:
- Open an issue with the "question" label
- Reach out to the maintainers
Thank you for contributing! 🎉