diff --git a/__manifest__.py b/__manifest__.py index 922d7b0..4550471 100644 --- a/__manifest__.py +++ b/__manifest__.py @@ -28,7 +28,7 @@ # or merged change. # ------------------------------------------------------------------------------ -__version__ = "1.2.3" +__version__ = "1.3.0" # --- Dependencies ------------------------------------------------------------- # List other odev plugins from which this current plugin depends. diff --git a/commands/code.py b/commands/code.py index a8823ec..0e22d85 100644 --- a/commands/code.py +++ b/commands/code.py @@ -21,7 +21,7 @@ def run(self): editor_class = Editor.__subclasses__()[0] try: - editor = editor_class(self._database, self.args.repository) + editor = editor_class(self._database, self.args) except ValueError as error: raise self.error(str(error)) from error diff --git a/common/editor.py b/common/editor.py index afe39d6..ae4b0f4 100644 --- a/common/editor.py +++ b/common/editor.py @@ -1,4 +1,5 @@ from abc import ABC, abstractmethod +from argparse import Namespace from pathlib import Path from typing import ClassVar, Optional @@ -20,17 +21,21 @@ class Editor(ABC): _display_name: ClassVar[str] """Display name of the code editor.""" - def __init__(self, database: DummyDatabase | LocalDatabase, repository: Optional[str] = None): + def __init__(self, database: DummyDatabase | LocalDatabase, cmd_args: Namespace): """Initialize the editor with a database or repository. :param database: The database linked to the project to open in the editor. - :param repository: The repository to open in the editor. + :param cmd_args: Arguments from the `Editor` command. """ + repository: Optional[str] = cmd_args.repository if isinstance(database, LocalDatabase) and repository is not None: raise ValueError("Cannot provide both database and repository") self.database = database """The database linked to the project to open in the editor.""" + self.cmd_args = cmd_args + """The command arguments.""" + self.repository: str = "odoo/odoo" """The repository to open in the editor."""