Unverified Commit 2a104075 authored by Sébastien Eustace's avatar Sébastien Eustace
Browse files

Add basic lock and install mechanism

parent e853ed1e
Loading
Loading
Loading
Loading
+3 −2
Changes for poetry/__init__.py: 3 added lines, 2 removed lines.
Original line number Diff line number Diff line
from poetry.console import Application
from .poetry import Poetry

__version__ = '0.1.0'
__version__ = Poetry.VERSION


console = Application('Poetry', __version__)
console = Application()
+1 −0
Changes for poetry/console/__init__.py: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
from .application import Application
+45 −0
Changes for poetry/console/application.py: 45 added lines, 0 removed lines.
Original line number Diff line number Diff line
import os

from cleo import Application as BaseApplication

from poetry.poetry import Poetry
from poetry.utils.venv import Venv

from .commands import AboutCommand
from .commands import InstallCommand


class Application(BaseApplication):

    def __init__(self):
        super().__init__('Poetry', Poetry.VERSION)

        self._poetry = None
        self._venv = Venv.create()

    @property
    def poetry(self) -> Poetry:
        if self._poetry is not None:
            return self._poetry

        self._poetry = Poetry.create(os.getcwd())

        return self._poetry

    @property
    def venv(self) -> Venv:
        return self._venv

    def get_default_commands(self) -> list:
        commands = super(Application, self).get_default_commands()

        return commands + [
            AboutCommand(),
            InstallCommand()
        ]

    def do_run(self, i, o) -> int:
        if self._venv.is_venv() and o.is_debug():
            o.writeln(f'Using virtualenv: <comment>{self._venv.venv}</>')

        return super().do_run(i, o)
+2 −0
Changes for poetry/console/commands/__init__.py: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
from .about import AboutCommand
from .install import InstallCommand
+16 −0
Changes for poetry/console/commands/about.py: 16 added lines, 0 removed lines.
Original line number Diff line number Diff line
from .command import Command


class AboutCommand(Command):
    """
    Short information about Poetry.

    about
    """

    def handle(self):
        self.line("""<info>Poetry - Package Management for Python</info>

<comment>Poetry is a dependency manager tracking local dependencies of your projects and libraries.
See <fg=blue>https://github.com/sdispater/poetry</> for more information.</comment>
""")
Loading