diff --git a/src/export_commands.py b/src/export_commands.py index 6e5d301..fba9e8e 100644 --- a/src/export_commands.py +++ b/src/export_commands.py @@ -1,27 +1,30 @@ import click + from database import get_collection @click.command() @click.argument('collection_id', type=int) @click.argument('output_file', type=click.Path(writable=True)) -@click.option('--markdown', is_flag=True, help='Creates a markdown checklist instead of a PDF') -def checklist(collection_id, output_file): +@click.option('--pdf', is_flag=True, help='Creates a PDF checklist instead of a markdown') +def checklist(collection_id, output_file, pdf): """ - Export a collection of items as a markdown checklist. + Export a collection of items as a markdown checklist or PDF. COLLECTION_ID: The ID of the collection to export. - OUTPUT_FILE: The file to write the markdown checklist to. - --markdown: Creates a markdown file instead of PDF + OUTPUT_FILE: The file to write the checklist to. + --pdf: Creates a markdown file instead of PDF. """ try: collection = get_collection(collection_id) - markdown_content = generate_markdown_checklist(collection) - - with open(output_file, 'w') as file: - file.write(markdown_content) - - click.echo(f"Collection {collection_id} exported to {output_file} successfully.") + if not pdf: + markdown_content = generate_markdown_checklist(collection) + with open(output_file, 'w') as file: + file.write(markdown_content) + click.echo(f"Collection {collection_id} exported to {output_file} as markdown successfully.") + else: + # generate_pdf_checklist(collection, output_file) + click.echo(f"Collection {collection_id} exported to {output_file} as PDF successfully.") except Exception as e: click.echo(f"An error occurred: {e}") @@ -45,3 +48,7 @@ def generate_markdown_checklist(collection): def pad_string(s, width): return s + ' ' * (width - len(s)) + + +if __name__ == "__main__": + pass diff --git a/src/test2.pdf b/src/test2.pdf new file mode 100644 index 0000000..a787c88 Binary files /dev/null and b/src/test2.pdf differ