Add version function support to CLI

This commit is contained in:
Joshua Boniface 2021-10-11 15:34:41 -04:00
parent cbbab46b55
commit 39fd85fcc3
1 changed files with 16 additions and 0 deletions

View File

@ -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