forked from HoloTech/customcmd-plugin
feat: Data and client framework
This commit is contained in:
+5
-6
@@ -2,9 +2,7 @@ import regex
|
||||
|
||||
from parsimonious.grammar import Grammar
|
||||
|
||||
from .context import ExecContext
|
||||
from .parser import Execuitor
|
||||
from .terms import ExecutorTerm
|
||||
from .parser import ExecContext, Execuitor, ExecutorTerm
|
||||
|
||||
fragment_re = regex.compile(r"\$(?<br>{(?:[^{}]++|(?&br))*})")
|
||||
|
||||
@@ -30,7 +28,7 @@ class ExecClient:
|
||||
term = self.execuitor.visit(tree)
|
||||
return term
|
||||
|
||||
async def run_command(self, ctx: ExecContext, command: str) -> str:
|
||||
async def run_command(self, ctx: ExecContext, command: str, dryrun=False) -> str:
|
||||
"""
|
||||
Process the given command string,
|
||||
executing and replacing each fragment.
|
||||
@@ -46,9 +44,10 @@ class ExecClient:
|
||||
|
||||
fragment = command[match.start() : match.end()]
|
||||
parsed = self._parse_fragment(fragment)
|
||||
fragment_result = await parsed.execute(ctx)
|
||||
if not dryrun:
|
||||
fragment_result = await parsed.execute(ctx)
|
||||
|
||||
result.append(fragment_result)
|
||||
result.append(fragment_result)
|
||||
last_end = match.end()
|
||||
|
||||
return "".join(result)
|
||||
|
||||
Reference in New Issue
Block a user