diff options
-rw-r--r-- | fietsboek/updater/cli.py | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/fietsboek/updater/cli.py b/fietsboek/updater/cli.py index 6a59100..45655d4 100644 --- a/fietsboek/updater/cli.py +++ b/fietsboek/updater/cli.py @@ -54,7 +54,8 @@ def cli(): help="Skip the safety question and just run the update", ) @click.argument("version", required=False) -def update(config, version, force): +@click.pass_context +def update(ctx, config, version, force): """Run the update process. Make sure to consult the documentation and ensure that you have a backup @@ -66,16 +67,17 @@ def update(config, version, force): updater = Updater(config) updater.load() if version and not updater.exists(version): - click.secho("Revision not found", fg="red") - return + ctx.fail(f"Version {version!r} not found") + version_str = ", ".join(updater.current_versions()) click.echo(f"Current version: {version_str}") if not version: heads = updater.heads() if len(heads) != 1: - click.secho("Ambiguous heads, please specify the version to update to", fg="red") - return + ctx.fail("Ambiguous heads, please specify the version to update to") + version = heads[0] + click.echo(f"Selected version: {version}") if not force: user_confirm() @@ -92,7 +94,8 @@ def update(config, version, force): help="Skip the safety question and just run the downgrade", ) @click.argument("version") -def downgrade(config, version, force): +@click.pass_context +def downgrade(ctx, config, version, force): """Run the downgrade process. Make sure to consult the documentation and ensure that you have a backup @@ -103,8 +106,8 @@ def downgrade(config, version, force): updater = Updater(config) updater.load() if version and not updater.exists(version): - click.secho("Revision not found", fg="red") - return + ctx.fail(f"Version {version!r} not found") + version_str = ", ".join(updater.current_versions()) click.echo(f"Current version: {version_str}") click.echo(f"Downgrade to version {version}") |