Skip to content

Commit

Permalink
Show version during debug (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
nickw444 committed Mar 25, 2019
1 parent b379f62 commit 9a2e3d4
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions nessclient/cli/__main__.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,33 @@
import logging

import click
import pkg_resources

from .events import events
from .send_command import send_command
from .server import server

LOG_LEVELS = ['error', 'warning', 'info', 'debug']

_LOGGER = logging.getLogger(__name__)


@click.group()
@click.option('--log-level', type=click.Choice(LOG_LEVELS), default='warning')
def cli(log_level: str):
level = getattr(logging, log_level.upper())
logging.basicConfig(level=level)
_LOGGER.debug('nessclient version: %s', get_version())


@cli.command()
def version():
"""Print installed package version."""
print(get_version())


def get_version():
return pkg_resources.get_distribution('nessclient').version


cli.add_command(events)
Expand Down

0 comments on commit 9a2e3d4

Please sign in to comment.