From 39fd85fcc39f6a2a4a967cf587f4142e393f3a63 Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Mon, 11 Oct 2021 15:34:41 -0400 Subject: [PATCH] Add version function support to CLI --- client-cli/pvc/pvc.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/client-cli/pvc/pvc.py b/client-cli/pvc/pvc.py index 655366b2..7197a4ba 100755 --- a/client-cli/pvc/pvc.py +++ b/client-cli/pvc/pvc.py @@ -51,6 +51,18 @@ default_store_data = { } +# +# Version function +# +def print_version(ctx, param, value): + if not value or ctx.resilient_parsing: + return + from pkg_resources import get_distribution + version = get_distribution('pvc').version + click.echo(f'Parallel Virtual Cluster version {version}') + ctx.exit() + + # # Data store handling functions # @@ -4793,6 +4805,10 @@ def task_init(confirm_flag, overwrite_flag): '-u', '--unsafe', '_unsafe', envvar='PVC_UNSAFE', is_flag=True, default=False, help='Allow unsafe operations without confirmation/"--yes" argument.' ) +@click.option( + '--version', is_flag=True, callback=print_version, + expose_value=False, is_eager=True +) def cli(_cluster, _debug, _quiet, _unsafe): """ Parallel Virtual Cluster CLI management tool