Skip to content

Commit

Permalink
new CLI command brother_ql info version (pklaus#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
pklaus committed Aug 10, 2018
1 parent a71fc4c commit b59f45f
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions brother_ql/cli.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python

# Python standard library
import logging
import logging, sys

# external dependencies
import click
Expand Down Expand Up @@ -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) """
Expand All @@ -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.')
Expand Down

0 comments on commit b59f45f

Please sign in to comment.