From 887da84439b92ec5555fdc35cdf39a9f8c423caf Mon Sep 17 00:00:00 2001 From: beucismis Date: Wed, 7 Jul 2021 19:36:40 +0300 Subject: [PATCH] Update cli.py --- backupill/cli.py | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/backupill/cli.py b/backupill/cli.py index 3ceb709..d82c263 100644 --- a/backupill/cli.py +++ b/backupill/cli.py @@ -3,25 +3,30 @@ import click import backupill as bp -@click.argument("file", required=True) @click.version_option(version=bp.__version__) -@click.command(context_settings=dict(help_option_names=["-h", "--help"])) -def main(file): +@click.option("--verbose", is_flag=1, help="Will print verbose messages.") +@click.option("-r", "--restore", is_flag=1, help="Restore PDF backup file.") +@click.option("-g", "--generate", is_flag=1, help="Generate PDF backup file.") +@click.argument("filename", type=click.Path(exists=1)) +@click.command(context_settings=dict(help_option_names=["--help"])) +def main(generate, restore, verbose, filename): """ \b Generates barcoded PDF to backup text files on paper. Source: https://github.com/beucismis/backupill - """ - if file: - if not os.path.isfile(file): - click.echo("Error: File '{}' not found!".format(file)) - exit() + \b + Example: + backupill -g filename.asc + backupill -r filename.pdf + """ - bp.generate_backup(file) - click.echo("Done!") - else: - click.echo("Usage: packupill FILENAME.asc") + if generate and not restore: + bp.generate_backup(click.format_filename(filename)) + click.echo("Generate backup done!") + if restore and not generate: + bp.restore_backup(click.format_filename(filename)) + click.echo("Generate restore done!") if __name__ == "__main__":