|
5 | 5 | import sys |
6 | 6 | from argparse import ArgumentParser |
7 | 7 | from pathlib import Path |
8 | | -from typing import cast |
9 | | - |
10 | | -from streamdeck.cli.errors import ( |
11 | | - DirectoryNotFoundError, |
12 | | -) |
13 | | -from streamdeck.cli.models import ( |
14 | | - CliArgsNamespace, |
15 | | -) |
| 8 | +from typing import Protocol, cast |
| 9 | + |
16 | 10 | from streamdeck.manager import PluginManager |
17 | 11 | from streamdeck.models.configs import PyProjectConfigs |
18 | 12 | from streamdeck.utils.logging import configure_streamdeck_logger |
|
22 | 16 |
|
23 | 17 |
|
24 | 18 |
|
| 19 | +class DirectoryNotFoundError(FileNotFoundError): |
| 20 | + """Custom exception to indicate that a specified directory was not found.""" |
| 21 | + def __init__(self, *args: object, directory: Path): |
| 22 | + super().__init__(*args) |
| 23 | + self.directory = directory |
| 24 | + |
| 25 | + |
| 26 | +class CliArgsNamespace(Protocol): |
| 27 | + """Represents the command-line arguments namespace.""" |
| 28 | + plugin_dir: Path | None |
| 29 | + action_scripts: list[str] | None |
| 30 | + |
| 31 | + # Args always passed in by StreamDeck software |
| 32 | + port: int |
| 33 | + pluginUUID: str # noqa: N815 |
| 34 | + registerEvent: str # noqa: N815 |
| 35 | + info: str # Actually a string representation of json object |
| 36 | + |
| 37 | + |
25 | 38 | def setup_cli() -> ArgumentParser: |
26 | 39 | """Set up the command-line interface for the script. |
27 | 40 |
|
@@ -56,7 +69,7 @@ def setup_cli() -> ArgumentParser: |
56 | 69 | return parser |
57 | 70 |
|
58 | 71 |
|
59 | | -def main(): |
| 72 | +def main() -> None: |
60 | 73 | """Main function to parse arguments, load actions, and execute them.""" |
61 | 74 | parser = setup_cli() |
62 | 75 | args = cast(CliArgsNamespace, parser.parse_args()) |
|
0 commit comments