Repository: python-poetry/poetry

Issue:
--short has no effect when `poetry version` is passed a new version
<!--
  Hi there! Thank you for discovering and submitting an issue.

  Before you submit this; let's make sure of a few things.
  Please make sure the following boxes are ticked if they are correct.
  If not, please try and fulfill these first.
-->

<!-- Checked checkbox should look like this: [x] -->
- [x] I am on the [latest](https://github.com/python-poetry/poetry/releases/latest) Poetry version.
- [x] I have searched the [issues](https://github.com/python-poetry/poetry/issues) of this repo and believe that this is not a duplicate.
- [x] If an exception occurs when executing a command, I executed it again in debug mode (`-vvv` option).

<!--
  Once those are done, if you're able to fill in the following list with your information,
  it'd be very helpful to whoever handles the issue.
-->

- **OS version and name**: Ubuntu 16.04
- **Poetry version**: 1.1.4
- **Link of a [Gist](https://gist.github.com/) with the contents of your pyproject.toml file**: n/a

## Issue
<!-- Now feel free to write your issue, but please be descriptive! Thanks again 🙌 ❤️ -->

Hi there!

Assuming the current version of a project is 0.1.0, this is what happens when trying to update to the next patch version with the `--short` option:

```console
$ poetry version patch --short
Bumping version from 0.1.0 to 0.1.1
```

Instead, I would like this to be output (only the new version number):

```console
$ poetry version patch --short
0.1.1
```

My use case is scripting: if the user only provides a bump rule to my script, I'd like to be able to easily parse the new version computed by poetry so that I can e.g. create a new git tag easily, and so on.

Thanks!


Discussion:
PS: I'm happy to contribute a PR. @stephsamson please let me know if I can proceed. :)
@sprt Yes, that would be much appreciate! 💫 I will assign you to this issue then.

Resolving patch:
diff --git a/poetry/console/commands/version.py b/poetry/console/commands/version.py
--- a/poetry/console/commands/version.py
+++ b/poetry/console/commands/version.py
@@ -48,11 +48,14 @@ def handle(self):
                 self.poetry.package.pretty_version, version
             )
 
-            self.line(
-                "Bumping version from <b>{}</> to <fg=green>{}</>".format(
-                    self.poetry.package.pretty_version, version
+            if self.option("short"):
+                self.line("{}".format(version))
+            else:
+                self.line(
+                    "Bumping version from <b>{}</> to <fg=green>{}</>".format(
+                        self.poetry.package.pretty_version, version
+                    )
                 )
-            )
 
             content = self.poetry.file.read()
             poetry_content = content["tool"]["poetry"]


Test patch:
diff --git a/tests/console/commands/test_version.py b/tests/console/commands/test_version.py
--- a/tests/console/commands/test_version.py
+++ b/tests/console/commands/test_version.py
@@ -51,3 +51,13 @@ def test_version_show(tester):
 def test_short_version_show(tester):
     tester.execute("--short")
     assert "1.2.3\n" == tester.io.fetch_output()
+
+
+def test_version_update(tester):
+    tester.execute("2.0.0")
+    assert "Bumping version from 1.2.3 to 2.0.0\n" == tester.io.fetch_output()
+
+
+def test_short_version_update(tester):
+    tester.execute("--short 2.0.0")
+    assert "2.0.0\n" == tester.io.fetch_output()