Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add command to delete a member #76

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions app/cli.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
# -*- coding: utf-8 -*-

"""Console script for tuesday."""
import sys
import click

from app.libs import member as memberlib

@click.command()
def main(args=None):
"""Console script for tuesday."""
click.echo("Replace this message by putting your code into "
"tuesday.cli.main")
click.echo("See click documentation at http://click.pocoo.org/")
return 0

@click.group()
def cli_group():
pass


@cli_group.command()
@click.option('--email', prompt='email',
help='The email of the Member to delete.')
def delete_user(email):
"""Delete a user"""
member = memberlib.get_by_email(email)
if member:
memberlib.delete(member['id'])
print(f"Member with the email : {email} - deleted successfully.")
else:
print(f"Member with the email : {email} - not found.")


cli = click.CommandCollection(sources=[cli_group])

if __name__ == "__main__":
sys.exit(main()) # pragma: no cover
cli()