Unverified Commit 408eef79 authored by Sébastien Eustace's avatar Sébastien Eustace
Browse files

Add the new command

parent dde73522
Loading
Loading
Loading
Loading
+17 −22
Changes for README.md: 17 added lines, 22 removed lines.
Original line number Diff line number Diff line
@@ -165,7 +165,7 @@ The `install` command reads the `poetry.toml` file from the current directory, r
and installs them.

```bash
poet install
poetry install
```

If there is a `poetry.lock` file in the current directory,
@@ -178,14 +178,14 @@ You can specify to the command that yo do not want the development dependencies
the `--no-dev` option.

```bash
poet install --no-dev
poetry install --no-dev
```

You can also specify the features you want installed by passing the `--f|--features` option (See [Features](#features) for more info)

```bash
poet install --features "mysql pgsql"
poet install -f mysql -f pgsql
poetry install --features "mysql pgsql"
poetry install -f mysql -f pgsql
```

#### Options
@@ -193,14 +193,13 @@ poet install -f mysql -f pgsql
* `--no-dev`: Do not install dev dependencies.
* `-f|--features`: Features to install (multiple values allowed).


### update

In order to get the latest versions of the dependencies and to update the `poetry.lock` file,
you should use the `update` command.

```bash
poet update
poetry update
```

This will resolve all dependencies of the project and write the exact versions into `poetry.lock`.
@@ -208,7 +207,7 @@ This will resolve all dependencies of the project and write the exact versions i
If you just want to update a few packages and not all, you can list them as such:

```bash
poet update requests toml
poetry update requests toml
```

#### Options
@@ -216,6 +215,15 @@ poet update requests toml
* `--no-progress`: Removes the progress display that can mess with some terminals or scripts which don't handle backspace characters.


### add

The `add` command adds new packages to the `poetry.toml` file from the current directory.

```bash
poetry add requests pendulum
```


### package

The `package` command builds the source and wheels archives.
@@ -241,7 +249,7 @@ It will automatically register the package before uploading if this is the first
This command searches for packages on a remote index.

```bash
poet search requests pendulum
poetry search requests pendulum
```

#### Options
@@ -253,20 +261,7 @@ poet search requests pendulum
This command locks (without installing) the dependencies specified in `poetry.toml`.

```bash
poet lock
```

#### Options

* `-f|--force`: Force locking.


### check

The `check` command will check if the `poetry.toml` file is valid.

```bash
poet check
poetry lock
```


+2 −0
Changes for poetry/console/application.py: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ from .commands import AboutCommand
from .commands import AddCommand
from .commands import InstallCommand
from .commands import LockCommand
from .commands import NewCommand
from .commands import UpdateCommand


@@ -44,6 +45,7 @@ class Application(BaseApplication):
            AddCommand(),
            InstallCommand(),
            LockCommand(),
            NewCommand(),
            UpdateCommand(),
        ]

+1 −0
Changes for poetry/console/commands/__init__.py: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -2,4 +2,5 @@ from .about import AboutCommand
from .add import AddCommand
from .install import InstallCommand
from .lock import LockCommand
from .new import NewCommand
from .update import UpdateCommand
+43 −0
Changes for poetry/console/commands/new.py: 43 added lines, 0 removed lines.
Original line number Diff line number Diff line
from pathlib import Path

from poetry.layouts import layout

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. }
    """

    def handle(self):
        layout_ = layout('standard')

        path = Path.cwd() / Path(self.argument('path'))
        name = self.option('name')
        if not name:
            name = path.name

        if path.exists():
            if list(path.glob('*')):
                # Directory is not empty. Aborting.
                raise RuntimeError(
                    'Destination <fg=yellow;bg=red>{}</>'
                    'exists and is not empty'.format(
                        path
                    )
                )

        readme_format = 'rst'

        layout_ = layout_(name, '0.1.0', readme_format=readme_format)
        layout_.create(path)

        self.line(
            'Created package <info>{}</> in <fg=blue>{}</>'
            .format(name, path.relative_to(Path.cwd()))
        )
+16 −0
Changes for poetry/layouts/__init__.py: 16 added lines, 0 removed lines.
Original line number Diff line number Diff line
from typing import Type

from .layout import Layout
from .standard import StandardLayout


_LAYOUTS = {
    'standard': StandardLayout
}


def layout(name: str) -> Type[Layout]:
    if name not in _LAYOUTS:
        raise ValueError('Invalid layout')

    return _LAYOUTS[name]
Loading