Commit e592fba9 by Konstantin Molchanov Committed by Sébastien Eustace

Add username and password options to publish command. (#83)

parent 1eef2c7f
...@@ -410,6 +410,8 @@ poetry publish ...@@ -410,6 +410,8 @@ poetry publish
* `-r|--repository`: The repository to register the package to (default: `pypi`). * `-r|--repository`: The repository to register the package to (default: `pypi`).
Should match a repository name set by the [`config`](#config) command. Should match a repository name set by the [`config`](#config) command.
* `--username (-u)`: The username to access the repository.
* `--password (-p)`: The password to access the repository.
### `config` ### `config`
......
...@@ -201,7 +201,8 @@ poetry publish ...@@ -201,7 +201,8 @@ poetry publish
* `--repository (-r)`: The repository to register the package to (default: `pypi`). * `--repository (-r)`: The repository to register the package to (default: `pypi`).
Should match a repository name set by the [`config`](#config) command. Should match a repository name set by the [`config`](#config) command.
* `--username (-u)`: The username to access the repository.
* `--password (-p)`: The password to access the repository.
## config ## config
......
...@@ -7,6 +7,8 @@ class PublishCommand(Command): ...@@ -7,6 +7,8 @@ class PublishCommand(Command):
publish publish
{ --r|repository= : The repository to publish the package to. } { --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. }
{ --no-build : Do not build the package before publishing. } { --no-build : Do not build the package before publishing. }
""" """
...@@ -29,4 +31,8 @@ the config command. ...@@ -29,4 +31,8 @@ the config command.
self.line('') self.line('')
publisher = Publisher(self.poetry, self.output) publisher = Publisher(self.poetry, self.output)
publisher.publish(self.option('repository')) publisher.publish(
self.option('repository'),
self.option('username'),
self.option('password')
)
...@@ -17,7 +17,7 @@ class Publisher: ...@@ -17,7 +17,7 @@ class Publisher:
self._io = io self._io = io
self._uploader = Uploader(poetry, io) self._uploader = Uploader(poetry, io)
def publish(self, repository_name): def publish(self, repository_name, username, password):
if repository_name: if repository_name:
self._io.writeln( self._io.writeln(
'Publishing <info>{}</info> (<comment>{}</comment>) ' 'Publishing <info>{}</info> (<comment>{}</comment>) '
...@@ -62,8 +62,7 @@ class Publisher: ...@@ -62,8 +62,7 @@ class Publisher:
url = config['repositories'][repository_name]['url'] url = config['repositories'][repository_name]['url']
username = None if not (username and password):
password = None
auth_file = Path(CONFIG_DIR) / 'auth.toml' auth_file = Path(CONFIG_DIR) / 'auth.toml'
if auth_file.exists(): if auth_file.exists():
with auth_file.open() as f: with auth_file.open() as f:
......
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