Skip to content

Commit 9a2e3d4

Browse files
authored
Show version during debug (#38)
1 parent b379f62 commit 9a2e3d4

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

nessclient/cli/__main__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,33 @@
11
import logging
22

33
import click
4+
import pkg_resources
45

56
from .events import events
67
from .send_command import send_command
78
from .server import server
89

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

12+
_LOGGER = logging.getLogger(__name__)
13+
1114

1215
@click.group()
1316
@click.option('--log-level', type=click.Choice(LOG_LEVELS), default='warning')
1417
def cli(log_level: str):
1518
level = getattr(logging, log_level.upper())
1619
logging.basicConfig(level=level)
20+
_LOGGER.debug('nessclient version: %s', get_version())
21+
22+
23+
@cli.command()
24+
def version():
25+
"""Print installed package version."""
26+
print(get_version())
27+
28+
29+
def get_version():
30+
return pkg_resources.get_distribution('nessclient').version
1731

1832

1933
cli.add_command(events)

0 commit comments

Comments
 (0)