You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|`-g`, `--generate`| - | Generate a tool with interactive inputs |
71
+
|`-l`, `--list`| - | Display the list of Python tools |
72
+
|`-s`, `--set`|`<prop>`, `<value>`| Apply new configuration value to a property |
73
+
|`-t`, `--tool`|`<tool>`| Launch a tool |
74
+
|`-h`, `--help`| - | Display the help menu |
75
+
|`-D`, `--debug`| - | Run in debugger mode |
76
+
|`-v`, `--version`| - | Display the program version |
77
77
78
78
[Summary](#summary)
79
79
80
80
### III.2 Main Program
81
81
82
-
Usage: `$ python main.py`
82
+
Execute the main script at the root of project folder with `$ python main.py`, when you arrived at the main menu, you can run directly all tools in registry
All tools can be created with `$ python main.py -g`, after that, the program ask you 3 questions about the new tool you want to create, once the tool was created, you must import it and enter it in the tool registry at [`tools/__init__.py`](tools/__init__.py)
114
+
115
+
Once the tool is declared in the [tools registry](#iv2-tools-registry), you can call it in the main program or as a command argument with `-t`
116
+
117
+
To recognize a tool, it is imperative to follow the Tool class nomenclature, while providing the following metadata for proper management:
118
+
119
+
-`command`: a tuple that references the tool's command and main alias, along with its acronym for display in the main menu
120
+
-`name`: a string representing the tool's name
121
+
-`path`: the absolute path to the tool's file (usually declared with the constant `__file__`)
122
+
-`version`: a string representing the tool's version (e.g., 0.1a, 1.0, 2.0)
123
+
112
124
[Summary](#summary)
113
125
114
126
### IV.1 Tool Structure
@@ -134,18 +146,18 @@ class Hello(Tool):
134
146
version ="0.1a"# Tool version
135
147
136
148
def__init__(self, args: list[str]):
137
-
# Initialization of Tool
138
-
super().__init__()
139
-
140
149
# Argument registry corresponding to lamdba registry index
141
150
self._args = [
142
151
(("-s", "--say-hello", ""), "Say a hello world")
143
-
]+self._args[:]
152
+
]
144
153
145
154
# Lamdba registry corresponding to argument registry index
146
155
self._execs = [
147
156
lambdax:self._sayHello(x)
148
-
] +self._execs[:]
157
+
]
158
+
159
+
# Initialization of Tool
160
+
super().__init__()
149
161
150
162
# _run(args) method to lauch method in lambda registry with arguments
151
163
# tips: you can rewrite the methode if you want to put some exception or rules to launch
@@ -165,14 +177,32 @@ class Hello(Tool):
165
177
166
178
### IV.2 Tools Registry
167
179
180
+
To use the tool you just created, you must declare it in the tool registry by importing it into the [`tools/__init__.py`](tools/__init__.py) file and declaring it in the `TOOLS` constant
181
+
182
+
```python
183
+
from core.tool import Tool
184
+
185
+
from tools.matrix import Matrix # Tool importation
186
+
...
187
+
188
+
TOOLS: tuple[Tool] = (
189
+
Matrix, # Tool declaration
190
+
...
191
+
)
192
+
""" Tools registry """
193
+
```
194
+
195
+
> [!note]
196
+
> Eventually, this method of tool declaration will be automated in the tool generation script
0 commit comments