Repository navigation
Expand file tree
/
Copy pathrules.py
More file actions
67 lines (49 loc) · 1.56 KB
/
Copy pathrules.py
File metadata and controls
67 lines (49 loc) · 1.56 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2026 Amir Farhadi
"""
Dragonfly voice commands for Caster Plugin Manager.
Provides deterministic, unbranched command grammar specs.
"""
from typing import Tuple
try:
from dragonfly import Function, MappingRule
except ImportError:
class MappingRule: # type: ignore[no-redef]
mapping = {}
def Function(fn): # type: ignore[misc] # noqa: N802
return fn
try:
from castervoice.lib.ctrl.mgr.rule_details import RuleDetails
except ImportError:
class RuleDetails: # type: ignore[no-redef]
def __init__(self, name=""):
self.name = name
from .runner_bridge import close_manager, open_manager_process, refresh_manager
def _cmd_open_manager():
open_manager_process()
def _cmd_refresh_manager():
refresh_manager()
def _cmd_close_manager():
close_manager()
class PluginManagerRule(MappingRule):
"""
Companion voice grammar rule for Plugin Manager.
Defines deterministic, unbranched command specs.
"""
mapping = {
"plugin manager": Function(_cmd_open_manager),
"plugin manager refresh": Function(_cmd_refresh_manager),
"plugin manager close": Function(_cmd_close_manager),
}
def get_rule() -> Tuple[type, RuleDetails]:
"""Returns rule class and RuleDetails configuration."""
details = RuleDetails(name="plugin manager")
return PluginManagerRule, details
__all__ = [
"PluginManagerRule",
"RuleDetails",
"get_rule",
"_cmd_open_manager",
"_cmd_refresh_manager",
"_cmd_close_manager",
]