How to use the cleo.option function in cleo

To help you get started, we’ve selected a few cleo examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sdispater / cleo / tests / inputs / test_api.py View on Github external
def test_option(self):
        validator = Integer()
        opt = option("foo", "f", "The foo option.", flag=True, validator=validator)

        self.assertIsInstance(opt, InputOption)
        self.assertEqual("foo", opt.get_name())
        self.assertEqual("The foo option.", opt.get_description())
        self.assertTrue(opt.is_flag())
        self.assertEqual(validator, opt.get_validator())

        opt = option(
            "foo",
            "f",
            "The foo option.",
            value_required=True,
            is_list=True,
            default=["default"],
            validator=validator,
        )
github python-poetry / poetry / poetry / console / commands / self / update.py View on Github external
from urllib2 import HTTPError
    from urllib2 import urlopen

from cleo import argument
from cleo import option

from ..command import Command


class SelfUpdateCommand(Command):

    name = "update"
    description = "Updates Poetry to the latest version."

    arguments = [argument("version", "The version to update to.", optional=True)]
    options = [option("preview", None, "Install prereleases.")]

    REPOSITORY_URL = "https://github.com/python-poetry/poetry"
    BASE_URL = REPOSITORY_URL + "/releases/download"
    FALLBACK_BASE_URL = "https://github.com/sdispater/poetry/releases/download"

    @property
    def home(self):
        from poetry.utils._compat import Path
        from poetry.utils.appdirs import expanduser

        home = Path(expanduser("~"))

        return home / ".poetry"

    @property
    def lib(self):
github python-poetry / poetry / poetry / console / commands / export.py View on Github external
from poetry.utils.exporter import Exporter

from .command import Command


class ExportCommand(Command):

    name = "export"
    description = "Exports the lock file to alternative formats."

    options = [
        option("format", "f", "Format to export to.", flag=False),
        option("output", "o", "The name of the output file.", flag=False),
        option("without-hashes", None, "Exclude hashes from the exported file."),
        option("dev", None, "Include development dependencies."),
        option(
            "extras",
            "E",
            "Extra sets of dependencies to include.",
            flag=False,
            multiple=True,
        ),
        option("with-credentials", None, "Include credentials for extra indices."),
    ]

    def handle(self):
        fmt = self.option("format")

        if fmt not in Exporter.ACCEPTED_FORMATS:
            raise ValueError("Invalid export format: {}".format(fmt))
github python-poetry / poetry / poetry / console / commands / debug / resolve.py View on Github external
description = "Debugs dependency resolution."

    arguments = [
        argument("package", "The packages to resolve.", optional=True, multiple=True)
    ]
    options = [
        option(
            "extras",
            "E",
            "Extras to activate for the dependency.",
            flag=False,
            multiple=True,
        ),
        option("python", None, "Python version(s) to use for resolution.", flag=False),
        option("tree", None, "Display the dependency tree."),
        option("install", None, "Show what would be installed for the current system."),
    ]

    loggers = ["poetry.repositories.pypi_repository"]

    def handle(self):
        from poetry.packages import ProjectPackage
        from poetry.puzzle import Solver
        from poetry.repositories.repository import Repository
        from poetry.semver import parse_constraint
        from poetry.utils.env import EnvManager

        packages = self.argument("package")

        if not packages:
            package = self.poetry.package
        else:
github python-poetry / poetry / poetry / console / commands / install.py View on Github external
from cleo import option

from .env_command import EnvCommand


class InstallCommand(EnvCommand):

    name = "install"
    description = "Installs the project dependencies."

    options = [
        option("no-dev", None, "Do not install the development dependencies."),
        option(
            "no-root", None, "Do not install the root package (the current project)."
        ),
        option(
            "dry-run",
            None,
            "Output the operations but do not execute anything "
            "(implicitly enables --verbose).",
        ),
        option(
            "extras",
            "E",
            "Extra sets of dependencies to install.",
            flag=False,
            multiple=True,
        ),
    ]

    help = """The install command reads the poetry.lock file from
the current directory, processes it, and downloads and installs all the
github python-poetry / poetry / poetry / console / commands / export.py View on Github external
from cleo import option

from poetry.utils.exporter import Exporter

from .command import Command


class ExportCommand(Command):

    name = "export"
    description = "Exports the lock file to alternative formats."

    options = [
        option("format", "f", "Format to export to.", flag=False),
        option("output", "o", "The name of the output file.", flag=False),
        option("without-hashes", None, "Exclude hashes from the exported file."),
        option("dev", None, "Include development dependencies."),
        option(
            "extras",
            "E",
            "Extra sets of dependencies to include.",
            flag=False,
            multiple=True,
        ),
        option("with-credentials", None, "Include credentials for extra indices."),
    ]

    def handle(self):
        fmt = self.option("format")
github python-poetry / poetry / poetry / console / commands / show.py View on Github external
# -*- coding: utf-8 -*-
from cleo import argument
from cleo import option

from .env_command import EnvCommand


class ShowCommand(EnvCommand):

    name = "show"
    description = "Shows information about packages."

    arguments = [argument("package", "The package to inspect", optional=True)]
    options = [
        option("no-dev", None, "Do not list the development dependencies."),
        option("tree", "t", "List the dependencies as a tree."),
        option("latest", "l", "Show the latest version."),
        option(
            "outdated",
            "o",
            "Show the latest version but only for packages that are outdated.",
        ),
        option(
            "all",
            "a",
            "Show all packages (even those not compatible with current system).",
        ),
    ]

    help = """The show command displays detailed information about a package, or
lists all packages available."""
github python-poetry / poetry / poetry / console / commands / add.py View on Github external
class AddCommand(EnvCommand, InitCommand):

    name = "add"
    description = "Adds a new dependency to pyproject.toml."

    arguments = [argument("name", "The packages to add.", multiple=True)]
    options = [
        option("dev", "D", "Add as a development dependency."),
        option(
            "extras",
            "E",
            "Extras to activate for the dependency.",
            flag=False,
            multiple=True,
        ),
        option("optional", None, "Add as an optional dependency."),
        option(
            "python",
            None,
            "Python version for which the dependency must be installed.",
            flag=False,
        ),
        option(
            "platform",
            None,
            "Platforms for which the dependency must be installed.",
            flag=False,
        ),
        option("allow-prereleases", None, "Accept prereleases."),
        option(
            "dry-run",
            None,
github python-poetry / poetry / poetry / console / commands / export.py View on Github external
from cleo import option

from poetry.utils.exporter import Exporter

from .command import Command


class ExportCommand(Command):

    name = "export"
    description = "Exports the lock file to alternative formats."

    options = [
        option("format", "f", "Format to export to.", flag=False),
        option("output", "o", "The name of the output file.", flag=False),
        option("without-hashes", None, "Exclude hashes from the exported file."),
        option("dev", None, "Include development dependencies."),
        option(
            "extras",
            "E",
            "Extra sets of dependencies to include.",
            flag=False,
            multiple=True,
        ),
        option("with-credentials", None, "Include credentials for extra indices."),
    ]

    def handle(self):
        fmt = self.option("format")

        if fmt not in Exporter.ACCEPTED_FORMATS:
            raise ValueError("Invalid export format: {}".format(fmt))
github python-poetry / poetry / poetry / console / commands / config.py View on Github external
from .command import Command


class ConfigCommand(Command):

    name = "config"
    description = "Manages configuration settings."

    arguments = [
        argument("key", "Setting key.", optional=True),
        argument("value", "Setting value.", optional=True, multiple=True),
    ]

    options = [
        option("list", None, "List configuration settings."),
        option("unset", None, "Unset configuration setting."),
        option("local", None, "Set/Get from the project's local configuration."),
    ]

    help = """This command allows you to edit the poetry config settings and repositories.

To add a repository:

    poetry config repositories.foo https://bar.com/simple/

To remove a repository (repo is a short alias for repositories):

    poetry config --unset repo.foo"""

    LIST_PROHIBITED_SETTINGS = {"http-basic", "pypi-token"}

    @property