|
| 1 | +# CONTRIBUTING |
| 2 | + |
| 3 | +## Coding Guidelines – toolsManager.py |
| 4 | + |
| 5 | +This document defines the best development practices to follow when contributing to the project. |
| 6 | + |
| 7 | +--- |
| 8 | + |
| 9 | +### 📁 Project Structure |
| 10 | + |
| 11 | +- `main.py`: Main entry point. |
| 12 | +- `setup.py`: Installer for project-specific dependencies (`.rar` file). |
| 13 | +- `core/`: Contains the core modules (configuration, tool management, etc.). |
| 14 | +- `tools/`: Contains each tool, 1 `.py` file per tool. |
| 15 | +- `dev`: Continuous development branch. |
| 16 | +- `master`: Stable branch only. |
| 17 | + |
| 18 | +--- |
| 19 | + |
| 20 | +### 🧱 Tool Writing Convention |
| 21 | + |
| 22 | +- Each tool must: |
| 23 | + - be in a separate file under tools/, |
| 24 | + - have the same name as the class (in PascalCase), |
| 25 | + - inherit from core.tool.Tool, |
| 26 | + - must implement the run() method. |
| 27 | + |
| 28 | +- Inheriting from Tool ensures consistent behavior and facilitates the overall management of tool modules. |
| 29 | + |
| 30 | +#### ✅ Minimum valid example: |
| 31 | + |
| 32 | +```python |
| 33 | +#!/usr/bin/env python3 |
| 34 | +# -*- coding: utf-8 -*- |
| 35 | + |
| 36 | +# tools/hello.py |
| 37 | + |
| 38 | +from core.tool import Tool |
| 39 | + |
| 40 | +class Hello(Tool): |
| 41 | + """ Say hello to the user |
| 42 | + """ |
| 43 | + |
| 44 | + command = (("hello", "hel"), "(hel)lo") |
| 45 | + name = "Hello" |
| 46 | + path = __file__ |
| 47 | + version = "0.1a" |
| 48 | + |
| 49 | + def __init__(self, args: list[str]): |
| 50 | + super().__init__() |
| 51 | + |
| 52 | + self._args = [ |
| 53 | + (("-s", "--say-hello", "<user>"), "Say hello to the user") |
| 54 | + ] + self._args[:] |
| 55 | + |
| 56 | + self._execs = [ |
| 57 | + lambda x:self._sayHello(x) |
| 58 | + ] + self._execs[:] |
| 59 | + |
| 60 | + self._run(args) |
| 61 | + |
| 62 | + def _sayHello(user: str) -> bool: |
| 63 | + print(f"Hello {user} ! :D") |
| 64 | + return(True) |
| 65 | +``` |
| 66 | + |
| 67 | +#### 🚨 Non-compliant example: |
| 68 | + |
| 69 | +```python |
| 70 | +# tools/hello.py |
| 71 | + |
| 72 | +# ❌ Missing inheritance from Tool |
| 73 | +class Hello: |
| 74 | + def run(self): |
| 75 | + ... |
| 76 | +``` |
| 77 | + |
| 78 | +## 🧪 Tests |
| 79 | + |
| 80 | +- Tests are currently manual. |
| 81 | +- Adding a tool must be followed by a test in main.py or CLI. |
| 82 | +- Errors must be handled properly via try/except. |
| 83 | + |
| 84 | +## 🧰 Coding Conventions |
| 85 | + |
| 86 | +- Follow PEP8 conventions. |
| 87 | +- Strong typing is recommended (str, bool, etc.). |
| 88 | +- Each public method must have a clear docstring. - Preferred use of logging over print() (if applicable). |
| 89 | + |
| 90 | +## 🔁 GitFlow |
| 91 | + |
| 92 | +- Each new tool or feature must start from a dedicated branch from dev. |
| 93 | +- Branches must be named feature/tool-name or fix/issue. |
| 94 | +- Always rebase before merging to dev. |
| 95 | +- The master branch should only receive tested and stable code. |
| 96 | +- Each merge to master must be accompanied by a versioned tag (v1.2.0, etc.). |
| 97 | + |
| 98 | +## 🚀 Release |
| 99 | + |
| 100 | +- When merging to master, add a Git tag and a GitHub release if possible. |
| 101 | +- Releases must contain: |
| 102 | + - a brief changelog, |
| 103 | + - a list of added/modified tools, |
| 104 | + - a version number. |
| 105 | + |
| 106 | +## 🤝 Contribution |
| 107 | + |
| 108 | +- Forks, pull requests, and issues welcome. |
| 109 | +- Please respect the structure and naming, and keep the code readable. |
0 commit comments