#!python

import click
import HyruleCompendium as compendium
from json import dumps

@click.group()
def hyrule():
    'Get items from the Hyrule compendium onto your command line'

@hyrule.command()
@click.argument('entry', required=True)
@click.option('--format', '-f', is_flag=True, help='Format the JSON response')
def get_entry(entry, format):
    'Get a specific entry'
    res = compendium.getEntry(entry)
    if format:
        click.echo(dumps(res, indent=4))
    else:
        click.echo(res)

@hyrule.command()
@click.argument('category', required=True)
@click.option('--format', '-f', is_flag=True, help='Format the JSON response')
def get_category(category, format):
    'Get items in a category'
    res = compendium.getCategory(category)
    if format:
        click.echo(dumps(res, indent=4))
    else:
        click.echo(res)

@hyrule.command()
@click.option('--format', '-f', is_flag=True, help='Format the JSON response')
def get_all(format):
    'Get all items in the compendium'
    res = compendium.getAllData()
    if format:
        click.echo(dumps(res, indent=4))
    else:
        click.echo(res)

hyrule()