Skip to content

Commit

Permalink
Expand version output to include library versions
Browse files Browse the repository at this point in the history
- Add new 'extra_version' field for commands so that they can report extra info,
  like the version number of external modules.
- Added Splunk Python SDK version to the output of '--version'.
  • Loading branch information
lowell80 committed Jun 1, 2019
1 parent 841ce39 commit 2b0ca02
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ksconf/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,10 @@ def build_cli_parser(do_formatter=False):
if error:
version_info.append(" {:15} {:10} {}".format(name, m, error))
else:
version_info.append(" {:15} {:10} OK".format(name, m))
info = " {:15} {:10} OK".format(name, m)
if cmd_cls.version_extra:
info = "{} ({})".format(info, cmd_cls.version_extra)
version_info.append(info)

# Common settings
'''
Expand Down
1 change: 1 addition & 0 deletions ksconf/commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ class KsconfCmd(object):
description = None
format = "default"
maturity = "alpha"
version_extra = None

def __init__(self, name):
self.name = name.lower()
Expand Down
2 changes: 2 additions & 0 deletions ksconf/commands/restpublish.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ def _handle_imports(cls):
return
import splunklib.client
g["splunklib"] = splunklib
import splunklib
cls.version_extra = "splunk-sdk {}".format(splunklib.__version__)

def register_args(self, parser):
# type: (ArgumentParser) -> None
Expand Down

0 comments on commit 2b0ca02

Please sign in to comment.