Added validators (closes #59)
This commit is contained in:
18
src/cpl_cli/validators/project_validator.py
Normal file
18
src/cpl_cli/validators/project_validator.py
Normal file
@@ -0,0 +1,18 @@
|
||||
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
|
||||
Reference in New Issue
Block a user