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
handler=actioneer.Performer([1, True]) # inits the command handler,
6
+
# the argument is preset contexts that will be passed to the command
7
+
# you can subclass Perfomer and overwride the "split_args", "get_options"
8
+
# and "get_flags"
9
+
10
+
11
+
defecho(*msg, message: str, flags: actioneer.Flags, options: actioneer.Options): # kwargs will be treated as contexts that will be passed to the command, this system used the annotations to find what to set as what
12
+
print(" ".join(msg))
13
+
print(message)
14
+
print(flags)
15
+
print(options)
16
+
raiseException("qwertjk")
17
+
18
+
# NOTE: all contexts are optional so you might set a context but it doesnt need to be set as a kwarg
19
+
20
+
21
+
echo=actioneer.Command(echo, flags=["test"], options={"channel": typing.Optional[int]}, performer=handler) # this will most likly be wrapped in other libs that use this
22
+
handler.register(echo) # adds it to the command handler
23
+
24
+
25
+
@handler.error
26
+
defbruh(e, *, message: str):
27
+
print(e)
28
+
print(message)
29
+
30
+
31
+
echo.invoke([""], ["bruh (the 'message', kwarg", actioneer.Flags({"test": True})])
32
+
handler.run("echo hello world -test --channel 123", ["bruh"]) # there is cmd.invoke but that doesnt handle arguments, flags and options
33
+
# ^ (1) ^ (2) ^ (3) ^ (4) ^ (5)
34
+
# 1 - command name
35
+
# 2 - command args
36
+
# 3 - flag
37
+
# 4 - option
38
+
# 5 - extra command context's that can be set when being invoked, ie channel,
0 commit comments