diff options
author | crupest <crupest@outlook.com> | 2024-11-11 01:12:29 +0800 |
---|---|---|
committer | Yuqian Yang <crupest@crupest.life> | 2025-01-19 12:46:54 +0800 |
commit | fc6cd0846eae8c7f7a50e18b654b1f14f7b7840f (patch) | |
tree | c0776129861a0147486790a565f8bd1a99d91d17 | |
parent | 8aec96d57a109e13a6254c77261c74b949407b05 (diff) | |
download | crupest-fc6cd0846eae8c7f7a50e18b654b1f14f7b7840f.tar.gz crupest-fc6cd0846eae8c7f7a50e18b654b1f14f7b7840f.tar.bz2 crupest-fc6cd0846eae8c7f7a50e18b654b1f14f7b7840f.zip |
HALF WORK: 2024.1.19
-rw-r--r-- | tools/cru-py/cru/service/_config.py | 9 | ||||
-rw-r--r-- | tools/cru-py/cru/service/_nginx.py | 31 | ||||
-rw-r--r-- | tools/cru-py/cru/template.py | 3 |
3 files changed, 40 insertions, 3 deletions
diff --git a/tools/cru-py/cru/service/_config.py b/tools/cru-py/cru/service/_config.py index eab33de..c28b071 100644 --- a/tools/cru-py/cru/service/_config.py +++ b/tools/cru-py/cru/service/_config.py @@ -178,7 +178,7 @@ class ConfigManager(AppCommandFeatureProvider): self._init_app_defined_items() def _init_app_defined_items(self) -> None: - prefix = self.app.app_id.upper() + prefix = self.config_name_prefix def _add_text(name: str, description: str) -> None: self.configuration.add( @@ -247,6 +247,10 @@ class ConfigManager(AppCommandFeatureProvider): ) @property + def config_name_prefix(self) -> str: + return self.app.app_id.upper() + + @property def configuration(self) -> Configuration: return self._configuration @@ -258,6 +262,9 @@ class ConfigManager(AppCommandFeatureProvider): self.reload_config_file() return self.configuration.to_str_dict() + def get_domain_item_name(self) -> str: + return f"{self.config_name_prefix}_DOMAIN" + def _set_with_default(self) -> None: if not self.configuration.all_not_set: raise AppConfigError( diff --git a/tools/cru-py/cru/service/_nginx.py b/tools/cru-py/cru/service/_nginx.py new file mode 100644 index 0000000..a291866 --- /dev/null +++ b/tools/cru-py/cru/service/_nginx.py @@ -0,0 +1,31 @@ +from argparse import Namespace + +from ._base import AppCommandFeatureProvider +from ._config import ConfigManager + + +class NginxManager(AppCommandFeatureProvider): + def __init__(self): + super().__init__("nginx-manager") + + def setup(self) -> None: + pass + + @property + def _template_domain_variable(self) -> str: + return self.app.get_feature(ConfigManager).get_domain_item_name() + + def _create_domain_regex(self): + raise NotImplementedError() + + def _get_domains(self) -> list[str]: + raise NotImplementedError() + + def get_command_info(self): + raise NotImplementedError() + + def setup_arg_parser(self, arg_parser): + raise NotImplementedError() + + def run_command(self, args: Namespace) -> None: + raise NotImplementedError() diff --git a/tools/cru-py/cru/template.py b/tools/cru-py/cru/template.py index 6e2cf24..eb8c8ab 100644 --- a/tools/cru-py/cru/template.py +++ b/tools/cru-py/cru/template.py @@ -4,8 +4,7 @@ import os.path from pathlib import Path from string import Template -from cru._path import CruPath - +from ._path import CruPath from ._iter import CruIterator from ._error import CruException |