Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
python-poetry
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
python-poetry
Commits
c939449e
Commit
c939449e
authored
Sep 27, 2019
by
Helena Ohlsen
Committed by
Arun Babu Neelicattu
Apr 01, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add option to version command to output version number only
Resolves: #1407
parent
ada04f9f
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
0 deletions
+15
-0
docs/docs/cli.md
+3
-0
poetry/console/commands/version.py
+5
-0
tests/console/commands/test_version.py
+7
-0
No files found.
docs/docs/cli.md
View file @
c939449e
...
@@ -423,6 +423,9 @@ bump rule is provided.
...
@@ -423,6 +423,9 @@ bump rule is provided.
The new version should ideally be a valid semver string or a valid bump rule:
The new version should ideally be a valid semver string or a valid bump rule:
`
patch
`, `
minor
`, `
major
`, `
prepatch
`, `
preminor
`, `
premajor
`, `
prerelease
`.
`
patch
`, `
minor
`, `
major
`, `
prepatch
`, `
preminor
`, `
premajor
`, `
prerelease
`.
## Options
* `
--short (-s)
`: Output the version number only.
## export
## export
...
...
poetry/console/commands/version.py
View file @
c939449e
from
cleo
import
argument
from
cleo
import
argument
from
cleo
import
option
from
.command
import
Command
from
.command
import
Command
...
@@ -18,6 +19,7 @@ class VersionCommand(Command):
...
@@ -18,6 +19,7 @@ class VersionCommand(Command):
optional
=
True
,
optional
=
True
,
)
)
]
]
options
=
[
option
(
"short"
,
"s"
,
"Output the version number only"
)]
help
=
"""
\
help
=
"""
\
The version command shows the current version of the project or bumps the version of
The version command shows the current version of the project or bumps the version of
...
@@ -58,6 +60,9 @@ patch, minor, major, prepatch, preminor, premajor, prerelease.
...
@@ -58,6 +60,9 @@ patch, minor, major, prepatch, preminor, premajor, prerelease.
self
.
poetry
.
file
.
write
(
content
)
self
.
poetry
.
file
.
write
(
content
)
else
:
else
:
if
self
.
option
(
"short"
):
self
.
line
(
"{}"
.
format
(
self
.
poetry
.
package
.
pretty_version
))
else
:
self
.
line
(
self
.
line
(
"<comment>{}</> <info>{}</>"
.
format
(
"<comment>{}</> <info>{}</>"
.
format
(
self
.
poetry
.
package
.
name
,
self
.
poetry
.
package
.
pretty_version
self
.
poetry
.
package
.
name
,
self
.
poetry
.
package
.
pretty_version
...
...
tests/console/commands/test_version.py
View file @
c939449e
...
@@ -45,3 +45,10 @@ def test_version_show(app):
...
@@ -45,3 +45,10 @@ def test_version_show(app):
tester
=
CommandTester
(
command
)
tester
=
CommandTester
(
command
)
tester
.
execute
()
tester
.
execute
()
assert
"simple-project 1.2.3
\n
"
==
tester
.
io
.
fetch_output
()
assert
"simple-project 1.2.3
\n
"
==
tester
.
io
.
fetch_output
()
def
test_short_version_show
(
app
):
command
=
app
.
find
(
"version"
)
tester
=
CommandTester
(
command
)
tester
.
execute
(
"--short"
)
assert
"1.2.3
\n
"
==
tester
.
io
.
fetch_output
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment