diff --git a/kafkaesque/__main__.py b/kafkaesque/__main__.py index 82c068d..42a63a9 100644 --- a/kafkaesque/__main__.py +++ b/kafkaesque/__main__.py @@ -1,6 +1,7 @@ import itertools import logging import operator +import tabulate import time import click @@ -97,6 +98,28 @@ def consume(topic, follow, fetch_size): ) +@cli.command() +@click.argument('topic') +def details(topic): + client = StrictRedis() + with client.pipeline(transaction=False) as pipeline: + pipeline.hgetall(topic) + pipeline.zcard('{}/pages'.format(topic)) + pipeline.zrange('{}/pages'.format(topic), -10, -1, withscores=True) + results = pipeline.execute() + + def header(label): + return '\n'.join(('-' * 80, label, '-' * 80)) + + print header('CONFIGURATION') + print tabulate.tabulate(results[0].items(), headers=('key', 'value')) + + print '' + + print header('PAGES ({} total)'.format(results[1])) + print tabulate.tabulate(results[2], headers=('page', 'offset')) + + if __name__ == '__main__': logging.basicConfig( level=logging.DEBUG, diff --git a/setup.py b/setup.py index 7f49d9d..325dabd 100644 --- a/setup.py +++ b/setup.py @@ -12,6 +12,7 @@ install_requires=( 'click', 'redis', + 'tabulate', ), tests_require=( 'pytest',