-
Notifications
You must be signed in to change notification settings - Fork 0
/
CommandHelp.py
29 lines (24 loc) · 894 Bytes
/
CommandHelp.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from typing import Callable
import inspect
from messages import *
class CommandHelp:
"""Try to dynamicaly generate a help menu for the command with function arguments.
Allow overwriting automaticaly generated commands by passing argument to the main decorator"""
def __init__(self, func: Callable, message=None, exemple=None) -> None:
if not message:
self.message = NoHelpAvailible()
else:
self.message = message
if not exemple:
self.exemple = (
func.__name__
+ " "
+ "".join(
[
f"<{str(e).split('=')[0]}>? " if "=" in str(e) else f"<{e}> "
for e in inspect.signature(func).parameters.values()
][1:]
)
)
else:
self.exemple = exemple