sh_cpl/src/cpl_cli/validators/project_validator.py

19 lines
646 B
Python
Raw Normal View History

2022-05-20 10:27:55 +02:00
from cpl_cli import Error
from cpl_cli.configuration import WorkspaceSettings, ProjectSettings
from cpl_core.configuration.validator_abc import ValidatorABC
class ProjectValidator(ValidatorABC):
def __init__(self, workspace: WorkspaceSettings, project: ProjectSettings):
self._workspace = workspace
self._project = project
ValidatorABC.__init__(self)
def validate(self) -> bool:
result = self._project is not None or self._workspace is not None
if not result:
Error.error('The command requires to be run in an CPL project, but a project could not be found.')
return result