From 46fe6f404cfa090f7afab00de7037f1231388250 Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Mon, 10 Oct 2022 21:03:15 +0200 Subject: fietsupdater: add a "status" subcommand --- fietsboek/updater/cli.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/fietsboek/updater/cli.py b/fietsboek/updater/cli.py index 2a7fc14..f00dfde 100644 --- a/fietsboek/updater/cli.py +++ b/fietsboek/updater/cli.py @@ -159,6 +159,29 @@ def revision(config, revision_id): click.echo(f"Revision saved to {filename}") +@cli.command("status") +@config_option +def status(config): + """Display information about the current version and available updates.""" + updater = Updater(config) + updater.load() + current = updater.current_versions() + heads = updater.heads() + click.secho("Current versions:", fg="yellow") + if current: + for i in current: + click.echo(i) + else: + click.secho("No current version", fg="red") + click.secho("Available updates:", fg="yellow") + updates = set(heads) - set(current) + if updates: + for i in updates: + click.echo(i) + else: + click.secho("All updates applied!", fg="green") + + @cli.command("help", hidden=True) @click.pass_context @click.argument("subcommand", required=False) -- cgit v1.2.3