From b59f45fa79143ca70b58833adb9b88e6d22c75a8 Mon Sep 17 00:00:00 2001 From: Philipp Klaus Date: Fri, 10 Aug 2018 11:58:50 +0200 Subject: [PATCH] new CLI command `brother_ql info version` (#34) --- brother_ql/cli.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/brother_ql/cli.py b/brother_ql/cli.py index b9b3c2f..d085a8e 100755 --- a/brother_ql/cli.py +++ b/brother_ql/cli.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # Python standard library -import logging +import logging, sys # external dependencies import click @@ -52,7 +52,7 @@ def discover_and_list_available_devices(backend): print(textual_description_discovered_devices(available_devices)) @cli.command() -@click.argument('info', click.Choice(('labels', 'models'))) +@click.argument('info', click.Choice(('labels', 'models', 'version'))) @click.pass_context def info(ctx, *args, **kwargs): """ list available choices (for labels or models) """ @@ -74,6 +74,19 @@ def info(ctx, *args, **kwargs): from brother_ql.output_helpers import textual_label_description print(textual_label_description(label_sizes)) + elif kwargs['info'] == 'version': + """ + Show the version of the package in the form: + ``brother_ql VERSION_STRING`` + """ + try: + import pkg_resources + version = pkg_resources.get_distribution("brother_ql").version + print("brother_ql %s" % version) + except: + logger.error("Couln't determine the version of the brother_ql package.") + sys.exit(1) + @cli.command('print', short_help='Print a label') @click.argument('images', nargs=-1, metavar='IMAGE [IMAGE] ...') @click.option('-l', '--label', type=click.Choice(label_sizes), envvar='BROTHER_QL_LABEL', help='The label (size, type - die-cut or endless). Run `brother_ql info labels` for a full list including ideal pixel dimensions.')