Created
August 7, 2020 20:04
-
-
Save CITGuru/1155faddb337100f8edca4a8c00f048a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from api import get_order, get_orders, create_orders | |
from auth import get_api | |
import sys | |
import click | |
from cli import take_user_order | |
api_key = get_api() | |
@click.group() | |
@click.version_option("1.0.0") | |
def main(): | |
"""A Simple Food Ordering App CLI""" | |
pass | |
@main.command() | |
def order(**kwargs): | |
"""Create orders""" | |
answer = take_user_order() | |
response = create_orders(answer, api_key) | |
click.echo(response.get("message")) | |
@main.command() | |
@click.argument('id') | |
def get(id): | |
"""Get order""" | |
order = get_order(id, api_key) | |
click.echo(f'{order["name"]} (x{order["quantity"]}) - {order["customer_name"]} ({order["customer_email"]}) - <{order["status"]}> - [{order["_id"]}]') | |
@main.command() | |
def orders(**kwargs): | |
"""Get orders""" | |
available_orders = get_orders(api_key) | |
for order in available_orders: | |
click.echo(f'{order["name"]} (x{order["quantity"]}) - {order["customer_name"]} ({order["customer_email"]}) - <{order["status"]}> - [{order["_id"]}]') | |
if __name__ == '__main__': | |
args = sys.argv | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment