Commit f2cd371a authored by Nik Khlestov's avatar Nik Khlestov

Updated structure of project list output, added logout option.

parent 1d8f8a07
## Install
`pip install git+https://git.teonite.net/mkhliestov/update-tracker-cli.git@UPD-20-cli-for-the-system`
\ No newline at end of file
`pip install git+https://git.teonite.net/mkhliestov/update-tracker-cli.git@UPD-20-cli-for-the-system`
## Usage
See `uptr --help`.
\ No newline at end of file
......@@ -7,6 +7,7 @@ from .main import settings, session, PROJECT_CONFIG_FILE
@click.group()
def project():
"""Create, list, pin projects."""
if settings.token is None:
ctx = click.get_current_context()
ctx.fail('No authorization token provided.')
......@@ -39,7 +40,8 @@ def list():
resp = session.get(url).json()
notification_message = []
for p in resp:
is_pinned_mark = 'PINNED' if int(p['id']) == settings.project_id else ''
notification_message.append(
'%s\t%s\t%s' % (p['name'], p['id'], int(p['id']) == settings.project_id)
'%s\t%s\t%s' % (p['name'], p['id'], is_pinned_mark)
)
click.echo('\n'.join(notification_message))
\ No newline at end of file
......@@ -67,3 +67,12 @@ def login(email, password):
# Notification for user
click.echo(data['detail'])
@user.command()
def logout():
with open(USER_CONFIG_FILE, 'r') as ifile:
conf = yaml.load(ifile.read()) or {}
conf['token'] = None
with open(USER_CONFIG_FILE, 'w') as ofile:
yaml.dump(conf, ofile)
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