Commit 5fc50555 by Sébastien Eustace

Update commands to use new Cleo helpers

parent 51bd2283
......@@ -123,10 +123,10 @@ description = "Cleo allows you to create beautiful and testable command-line int
name = "cleo"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
version = "0.7.2"
version = "0.7.4"
[package.dependencies]
clikit = ">=0.2.0,<0.3.0"
clikit = ">=0.2.4,<0.3.0"
pastel = ">=0.1.0,<0.2.0"
pylev = ">=1.3,<2.0"
......@@ -145,7 +145,7 @@ description = "CliKit is a group of utilities to build beautiful and testable co
name = "clikit"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
version = "0.2.3"
version = "0.2.4"
[package.dependencies]
pastel = ">=0.1.0,<0.2.0"
......@@ -923,7 +923,7 @@ docs = ["sphinx", "jaraco.packaging (>=3.2)", "rst.linker (>=1.9)"]
testing = ["pytest (>=3.5,<3.7.3 || >3.7.3)", "pytest-checkdocs", "pytest-flake8", "pathlib2", "more-itertools"]
[metadata]
content-hash = "9485e088cf3b45d2cff74b6dc625373d9aee736721cc4ae0cb9c951e829a03c6"
content-hash = "f3163ab56506c745d9250f9c04ea512d4996068c85770092590ffb079b465db0"
python-versions = "~2.7 || ^3.4"
[metadata.hashes]
......@@ -937,9 +937,9 @@ cachy = ["b71513e5a38ce90c1280c02b7d8d6bb3fdf64666c9cc0584f2479afea097d56c", "b7
certifi = ["59b7658e26ca9c7339e00f8f4636cdfe59d34fa37b9b04f6f9e9926b3cece1a5", "b26104d6835d1f5e49452a26eb2ff87fe7090b89dfcaee5ea2212697e1e1d7ae"]
cfgv = ["6e9f2feea5e84bc71e56abd703140d7a2c250fc5ba38b8702fd6a68ed4e3b2ef", "e7f186d4a36c099a9e20b04ac3108bd8bb9b9257e692ce18c8c3764d5cb12172"]
chardet = ["84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae", "fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691"]
cleo = ["7a5000de616de42fd78f968192651b9174bf333a9079fc9d68ccc672ddfd3624", "a39fa806fd3f64ff0ae4e3a55bb80c8ce60ca73634e13619731d63a04a63be69"]
cleo = ["58d26642fa608a1515093275cd98875100c7d50f01fc1f3bbb7a78dbb73e4b14", "9b7d706309412e43d00723ed3074a300cd7879a0c685f4fef0b5052d7f4ab71f"]
click = ["2335065e6395b9e67ca716de5f7526736bfa6ceead690adf616d925bdc622b13", "5b94b49521f6456670fdb30cd82a4eca9412788a93fa6dd6df72c94d5a8ff2d7"]
clikit = ["7bbd38fcb912058c689a03f487a66f8d1eb1f486bc5cf68d4a5798093bd0217f", "e23ac911afb7079ae0e4d89af73ee0d31c8952c64ef4fcf76bcd46bfde9aabaa"]
clikit = ["a7597999555aeb2ce9946f07187f690ab6864213f337e51250178c4bd19bd810", "d6807cf4a41e6b981b056075c0aefca2db1dabc597ed18fa4d92b8b2e2678835"]
colorama = ["05eed71e2e327246ad6b38c540c4a3117230b19679b875190486ddd2d721422d", "f8ac84de7840f5b9c4e3347b3c1eaa50f7e49c2b07596221daec5edaabbd7c48"]
configparser = ["8be81d89d6e7b4c0d4e44bcc525845f6da25821de80cb5e06e7e0238a2899e32", "da60d0014fd8c55eb48c1c5354352e363e2d30bbf7057e5e171a468390184c75"]
contextlib2 = ["509f9419ee91cdd00ba34443217d5ca51f5a364a404e1dce9e8979cea969ca48", "f5260a6e679d2ff42ec91ec5252f4eeffdcf21053db9113bd0a8e4d953769c00"]
......
......@@ -9,7 +9,6 @@ from .commands import AddCommand
from .commands import BuildCommand
from .commands import CheckCommand
from .commands import ConfigCommand
from .commands import DevelopCommand
from .commands import ExportCommand
from .commands import InitCommand
from .commands import InstallCommand
......@@ -18,7 +17,6 @@ from .commands import NewCommand
from .commands import PublishCommand
from .commands import RemoveCommand
from .commands import RunCommand
from .commands import ScriptCommand
from .commands import SearchCommand
from .commands import ShellCommand
from .commands import ShowCommand
......@@ -68,7 +66,6 @@ class Application(BaseApplication):
BuildCommand(),
CheckCommand(),
ConfigCommand(),
DevelopCommand(),
ExportCommand(),
InitCommand(),
InstallCommand(),
......@@ -77,7 +74,6 @@ class Application(BaseApplication):
PublishCommand(),
RemoveCommand(),
RunCommand(),
ScriptCommand(),
SearchCommand(),
ShellCommand(),
ShowCommand(),
......
......@@ -3,7 +3,6 @@ from .add import AddCommand
from .build import BuildCommand
from .check import CheckCommand
from .config import ConfigCommand
from .develop import DevelopCommand
from .export import ExportCommand
from .init import InitCommand
from .install import InstallCommand
......@@ -12,7 +11,6 @@ from .new import NewCommand
from .publish import PublishCommand
from .remove import RemoveCommand
from .run import RunCommand
from .script import ScriptCommand
from .search import SearchCommand
from .shell import ShellCommand
from .show import ShowCommand
......
......@@ -2,11 +2,10 @@ from .command import Command
class AboutCommand(Command):
"""
Short information about Poetry.
about
"""
name = "about"
description = "Short information about Poetry."
def handle(self):
self.line(
......
from cleo import argument
from cleo import option
from .init import InitCommand
from .env_command import EnvCommand
class AddCommand(EnvCommand, InitCommand):
"""
Add a new dependency to <comment>pyproject.toml</>.
add
{ name* : Packages to add. }
{ --D|dev : Add package as development dependency. }
{ --git= : The url of the Git repository. }
{ --path= : The path to a dependency. }
{ --E|extras=* : Extras to activate for the dependency. }
{ --optional : Add as an optional dependency. }
{ --python= : Python version( for which the dependencies must be installed. }
{ --platform= : Platforms for which the dependencies must be installed. }
{ --allow-prereleases : Accept prereleases. }
{ --dry-run : Outputs the operations but will not execute anything
(implicitly enables --verbose). }
"""
name = "add"
description = "Add a new dependency to <comment>pyproject.toml</>."
arguments = [argument("name", "Packages to add.", multiple=True)]
options = [
option("dev", "D", "Add package as development dependency."),
option("git", None, "The url of the Git repository.", flag=False),
option("path", None, "The path to a dependency.", flag=False),
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 dependencies must be installed.",
flag=False,
),
option(
"platform",
None,
"Platforms for which the dependencies must be installed.",
flag=False,
),
option("allow-prereleases", None, "Accept prereleases."),
option(
"dry-run",
None,
"Outputs the operations but will not execute anything (implicitly enables --verbose).",
),
]
help = """The add command adds required packages to your <comment>pyproject.toml</> and installs them.
......
from cleo import option
from .env_command import EnvCommand
class BuildCommand(EnvCommand):
"""
Builds a package, as a tarball and a wheel by default.
build
{ --f|format= : Limit the format to either wheel or sdist. }
"""
name = "build"
description = "Builds a package, as a tarball and a wheel by default."
options = [
option("format", "f", "Limit the format to either wheel or sdist.", flag=True)
]
def handle(self):
from poetry.masonry import Builder
......
......@@ -4,11 +4,9 @@ from .clear import CacheClearCommand
class CacheCommand(Command):
"""
Interact with Poetry's cache.
cache
"""
name = "cache"
description = "Interact with Poetry's cache"
commands = [CacheClearCommand()]
......
import os
from cleo import argument
from cleo import option
from ..command import Command
class CacheClearCommand(Command):
"""
Clears poetry's cache.
clear
{ cache : The name of the cache to clear. }
{ --all : Clear all caches. }
"""
name = "clear"
description = "Clears Poetry's cache."
arguments = [argument("cache", description="The name of the cache to clear.")]
options = [option("all", description="Clear all caches.")]
def handle(self):
from cachy import CacheManager
......
......@@ -2,11 +2,9 @@ from .command import Command
class CheckCommand(Command):
"""
Checks the validity of the <comment>pyproject.toml</comment> file.
check
"""
name = "check"
description = "Checks the validity of the <comment>pyproject.toml</comment> file."
def handle(self):
# Load poetry and display errors, if any
......
import json
import re
from cleo import argument
from cleo import option
from .command import Command
......@@ -14,15 +17,19 @@ AUTH_TEMPLATE = """[http-basic]
class ConfigCommand(Command):
"""
Sets/Gets config options.
config
{ key? : Setting key. }
{ value?* : Setting value. }
{ --list : List configuration settings }
{ --unset : Unset configuration setting }
"""
name = "config"
description = "Sets/Gets config options."
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."),
]
help = """This command allows you to edit the poetry config settings and repositories.
......
......@@ -4,10 +4,8 @@ from .resolve import DebugResolveCommand
class DebugCommand(Command):
"""
Debug various elements of Poetry.
debug
"""
name = "debug"
description = "Debug various elements of Poetry."
commands = [DebugInfoCommand().default(), DebugResolveCommand()]
import os
import sys
from clikit.args import StringArgs
......@@ -7,11 +6,9 @@ from ..command import Command
class DebugInfoCommand(Command):
"""
Shows debug information.
info
"""
name = "info"
description = "Shows debug information."
def handle(self):
poetry_python_version = ".".join(str(s) for s in sys.version_info[:3])
......
......@@ -2,20 +2,32 @@ import re
from typing import List
from cleo import argument
from cleo import option
from ..command import Command
class DebugResolveCommand(Command):
"""
Debugs dependency resolution.
resolve
{ package?* : packages to resolve. }
{ --E|extras=* : Extras to activate for the dependency. }
{ --python= : Python version(s) to use for resolution. }
{ --tree : Displays the dependency tree. }
{ --install : Show what would be installed for the current system. }
"""
name = "resolve"
description = "Debugs dependency resolution."
arguments = [
argument("package", "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, "Displays the dependency tree."),
option("install", None, "Show what would be installed for the current system."),
]
loggers = ["poetry.repositories.pypi_repository"]
......
......@@ -7,11 +7,9 @@ from .use import EnvUseCommand
class EnvCommand(Command):
"""
Interact with Poetry's project environments.
env
"""
name = "env"
description = "Interact with Poetry's project environments."
commands = [EnvInfoCommand(), EnvListCommand(), EnvRemoveCommand(), EnvUseCommand()]
......
from cleo import option
from ..command import Command
class EnvInfoCommand(Command):
"""
Display information about the current environment.
info
{--p|path : Only display the environment's path}
"""
name = "info"
description = "Display information about the current environment."
options = [option("path", "p", "Only display the environment's path.")]
def handle(self):
from poetry.utils.env import EnvManager
......
from cleo import option
from ..command import Command
class EnvListCommand(Command):
"""
List all virtualenvs associated with the current project.
list
{--full-path : Output the full paths of the virtualenvs}
"""
name = "list"
description = "List all virtualenvs associated with the current project."
options = [option("full-path", None, "Output the full paths of the virtualenvs.")]
def handle(self):
from poetry.utils.env import EnvManager
......
from cleo import argument
from ..command import Command
class EnvRemoveCommand(Command):
"""
Remove a specific virtualenv associated with the project.
remove
{python : The python executable to remove the virtualenv for.}
"""
name = "remove"
description = "Remove a specific virtualenv associated with the project."
arguments = [
argument("python", "The python executable to remove the virtualenv for.")
]
def handle(self):
from poetry.utils.env import EnvManager
......
from cleo import argument
from ..command import Command
class EnvUseCommand(Command):
"""
Activate or create a new virtualenv for the current project.
use
{python : The python executable to use.}
"""
name = "use"
description = "Activate or create a new virtualenv for the current project."
arguments = [argument("python", "The python executable to use.")]
def handle(self):
from poetry.utils.env import EnvManager
......
from poetry.utils.exporter import Exporter
from cleo import option
from .command import Command
class ExportCommand(Command):
"""
Exports the lock file to alternative formats.
export
{--f|format= : Format to export to.}
{--without-hashes : Exclude hashes from the exported file.}
{--dev : Include development dependencies.}
"""
name = "export"
description = "Exports the lock file to alternative formats."
options = [
option("format", "f", "Format to export to.", flag=False),
option("without-hashes", None, "Exclude hashes from the exported file."),
option("dev", None, "Include development dependencies."),
]
def handle(self):
fmt = self.option("format")
......
......@@ -6,24 +6,41 @@ import re
from typing import List
from typing import Tuple
from cleo import option
from .command import Command
from .env_command import EnvCommand
class InitCommand(Command):
"""
Creates a basic <comment>pyproject.toml</> file in the current directory.
init
{--name= : Name of the package}
{--description= : Description of the package}
{--author= : Author name of the package}
{--dependency=* : Package to require with an optional version constraint,
e.g. requests:^2.10.0 or requests=2.11.1}
{--dev-dependency=* : Package to require for development with an optional version constraint,
e.g. requests:^2.10.0 or requests=2.11.1}
{--l|license= : License of the package}
"""
name = "init"
description = (
"Creates a basic <comment>pyproject.toml</> file in the current directory."
)
options = [
option("name", None, "Name of the package.", flag=False),
option("description", None, "Description of the package.", flag=False),
option("author", None, "Author name of the package.", flag=False),
option(
"dependency",
None,
"Package to require with an optional version constraint, "
"e.g. requests:^2.10.0 or requests=2.11.1.",
flag=False,
multiple=True,
),
option(
"dev-dependency",
None,
"Package to require for development with an optional version constraint, "
"e.g. requests:^2.10.0 or requests=2.11.1.",
flag=False,
multiple=True,
),
option("license", "l", "License of the package.", flag=False),
]
help = """\
The <info>init</info> command creates a basic <comment>pyproject.toml</> file in the current directory.
......
import os
from cleo import option
from .env_command import EnvCommand
class InstallCommand(EnvCommand):
"""
Installs the project dependencies.
install
{ --no-dev : Do not install dev dependencies. }
{ --no-root : Do not install the root package (your project). }
{ --dry-run : Outputs the operations but will not execute anything
(implicitly enables --verbose). }
{ --E|extras=* : Extra sets of dependencies to install. }
{ --develop=* : Install given packages in development mode. }
"""
name = "install"
description = "Installs the project dependencies."
options = [
option("no-dev", None, "Do not install dev dependencies."),
option(
"no-root", None, "Do not install the root package (the current project)."
),
option(
"dry-run",
None,
"Outputs the operations but will not execute anything "
"(implicitly enables --verbose).",
),
option(
"extras",
"E",
"Extra sets of dependencies to install.",
flag=False,
multiple=True,
),
option(
"develop",
None,
"Install given packages in development mode.",
flag=False,
multiple=True,
),
]
help = """The <info>install</info> command reads the <comment>poetry.lock</> file from
the current directory, processes it, and downloads and installs all the
......
......@@ -2,11 +2,9 @@ from .env_command import EnvCommand
class LockCommand(EnvCommand):
"""
Locks the project dependencies.
lock
"""
name = "lock"
description = "Locks the project dependencies."
help = """The <info>lock</info> command reads the <comment>pyproject.toml</> file from
the current directory, processes it, and locks the depdencies in the <comment>poetry.lock</> file.
......
from cleo import argument
from cleo import option
from .command import Command
class NewCommand(Command):
"""
Creates a new Python project at <path>
new
{ path : The path to create the project at. }
{ --name= : Set the resulting package name. }
{ --src : Use the src layout for the project. }
"""
name = "new"
description = "Creates a new Python project at <path>"
arguments = [argument("path", "The path to create the project at.")]
options = [
option("name", None, "Set the resulting package name.", flag=False),
option("src", None, "Use the src layout for the project."),
]
def handle(self):
from poetry.layouts import layout
......
from cleo import option
from .command import Command
class PublishCommand(Command):
"""
Publishes a package to a remote repository.
publish
{ --r|repository= : The repository to publish the package to. }
{ --u|username= : The username to access the repository. }
{ --p|password= : The password to access the repository. }
{ --build : Build the package before publishing. }
"""
name = "publish"
description = "Publishes a package to a remote repository."
options = [
option(
"repository", "r", "The repository to publish the package to.", flag=False
),
option("username", "u", "The username to access the repository.", flag=False),
option("password", "p", "The password to access the repository.", flag=False),
option("build", None, "Build the package before publishing."),
]
help = """The publish command builds and uploads the package to a remote repository.
......
from cleo import argument
from cleo import option
from .env_command import EnvCommand
class RemoveCommand(EnvCommand):
"""
Removes a package from the project dependencies.
remove
{ packages* : Packages that should be removed. }
{--D|dev : Removes a package from the development dependencies. }
{--dry-run : Outputs the operations but will not execute anything
(implicitly enables --verbose). }
"""
name = "remove"
description = "Removes a package from the project dependencies."
arguments = [argument("packages", "Packages that should be removed", multiple=True)]
options = [
option("dev", "D", "Removes a package from the development dependencies."),
option(
"dry-run",
None,
"Outputs the operations but will not execute anything "
"(implicitly enables --verbose).",
),
]
help = """The <info>remove</info> command removes a package from the current
list of installed packages
......
from cleo import argument
from .env_command import EnvCommand
class RunCommand(EnvCommand):
"""
Runs a command in the appropriate environment.
run
{ args* : The command and arguments/options to run. }
"""
name = "run"
description = "Runs a command in the appropriate environment."
arguments = [
argument("args", "The command and arguments/options to run.", multiple=True)
]
def __init__(self): # type: () -> None
from poetry.console.args.run_args_parser import RunArgsParser
......
from cleo import argument
from cleo import option
from .command import Command
class SearchCommand(Command):
"""
Searches for packages on remote repositories.
search
{ tokens* : The tokens to search for. }
{ --N|only-name : Search only in name. }
"""
name = "search"
description = "Searches for packages on remote repositories."
arguments = [argument("tokens", "The tokens to search for.", multiple=True)]
options = [option("only-name", "N", "Search only in name.")]
def handle(self):
from poetry.repositories.pypi_repository import PyPiRepository
......
......@@ -4,11 +4,9 @@ from .update import SelfUpdateCommand
class SelfCommand(Command):
"""
Interact with Poetry directly.
"""
name = "self"
description = "Interact with Poetry directly."
commands = [SelfUpdateCommand()]
......
......@@ -15,17 +15,19 @@ except ImportError:
from urllib2 import HTTPError
from urllib2 import urlopen
from cleo import argument
from cleo import option
from ..command import Command
class SelfUpdateCommand(Command):
"""
Updates poetry to the latest version.
update
{ version? : The version to update to. }
{ --preview : Install prereleases. }
"""
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.")]
BASE_URL = "https://github.com/sdispater/poetry/releases/download"
......
......@@ -7,11 +7,9 @@ from .env_command import EnvCommand
class ShellCommand(EnvCommand):
"""
Spawns a shell within the virtual environment.
shell [options]
"""
name = "shell"
description = "Spawns a shell within the virtual environment."
help = """The <info>shell</> command spawns a shell, according to the
<comment>$SHELL</> environment variable, within the virtual environment.
......
# -*- coding: utf-8 -*-
from cleo import argument
from cleo import option
from .env_command import EnvCommand
class ShowCommand(EnvCommand):
"""
Shows information about packages.
show
{ package? : Package to inspect. }
{ --no-dev : Do not list the dev dependencies. }
{ --t|tree : List the dependencies as a tree. }
{ --l|latest : Show the latest version. }
{ --o|outdated : Show the latest version
but only for packages that are outdated. }
{ --a|all : Show all packages (even those not compatible with current system). }
"""
name = "show"
description = "Shows information about packages."
arguments = [argument("package", "Package to inspect", optional=True)]
options = [
option("no-dev", None, "Do not list the dev 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."""
......
from cleo import argument
from cleo import option
from .env_command import EnvCommand
class UpdateCommand(EnvCommand):
"""
Update dependencies as according to the <comment>pyproject.toml</> file.
update
{ packages?* : The packages to update. }
{ --no-dev : Do not install dev dependencies. }
{ --dry-run : Outputs the operations but will not execute anything
(implicitly enables --verbose). }
{ --lock : Do not perform install (only update the lockfile). }
"""
name = "update"
description = (
"Update dependencies as according to the <comment>pyproject.toml</> file."
)
arguments = [
argument("packages", "The packages to update", optional=True, multiple=True)
]
options = [
option("no-dev", None, "Do not update dev dependencies."),
option(
"dry-run",
None,
"Output the operations but do not execute anything "
"(implicitly enables --verbose).",
),
option("lock", None, "Do not perform operations (only update the lockfile)."),
]
loggers = ["poetry.repositories.pypi_repository"]
......
from cleo import argument
from .command import Command
class VersionCommand(Command):
"""
Bumps the version of the project.
version
{ version=patch : The version number or the rule to update version }
"""
name = "version"
description = "Bumps the version of the project."
arguments = [
argument(
"version",
"The version number or the rule to update the version.",
optional=True,
default="patch",
)
]
help = """\
The version command bumps the version of the project
......
......@@ -23,7 +23,7 @@ classifiers = [
# Requirements
[tool.poetry.dependencies]
python = "~2.7 || ^3.4"
cleo = "^0.7.2"
cleo = "^0.7.4"
requests = "^2.18"
cachy = "^0.2"
requests-toolbelt = "^0.8.0"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment