From b6a4929d93e667150b6c94a5bf0736db2cca0991 Mon Sep 17 00:00:00 2001 From: nojhan Date: Wed, 26 Jul 2023 22:09:07 +0200 Subject: [PATCH] first commit --- .klyban.csv | 4 ++++ klyban.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 .klyban.csv create mode 100644 klyban.py diff --git a/.klyban.csv b/.klyban.csv new file mode 100644 index 0000000..8c48dc4 --- /dev/null +++ b/.klyban.csv @@ -0,0 +1,4 @@ +STATUS,ID,TITLE,DETAILS,TAG,DEADLINE +DOING,1,print card,pretty print fixed-width cards given a content,klyban, +TODO,2,print table,pretty print set of cards on each column,klyban, +TODO,3,nested prints,print cards within cards,klyban, diff --git a/klyban.py b/klyban.py new file mode 100644 index 0000000..e97d62d --- /dev/null +++ b/klyban.py @@ -0,0 +1,32 @@ +import sys + +import agate +import click + +# Global group holding global options. +@click.group() +@click.option('-i', '--input', default='.klyban.csv', type=click.Path(writable=True, readable=True, allow_dash=True)) +@click.pass_context +def cli(context,input): + # ensure that context.obj exists and is a dict (in case `cli()` is called + # by means other than the `if` block below) + context.ensure_object(dict) + context.obj['input'] = input + + +@cli.command() +@click.pass_context +def show(context): + with click.open_file(context.obj['input'], mode='r') as fd: + table = agate.Table.from_csv(fd) + + table.print_table(output = sys.stdout) + +@cli.command() +@click.pass_context +def config(context): + click.echo('Configuration:') + click.echo(f"Data file: `{context.obj['input']}`") + +if __name__ == '__main__': + cli(obj={})