Skip to content

Commit bbd0762

Browse files
committed
Bump version to 1.2.4 and add version command to BloodHound CLI
This commit updates the version to 1.2.4 in the project metadata and introduces a new command to display the CLI version. The README has been updated to include usage instructions for the version command, ensuring users can easily check the current version of the tool.
1 parent 8b78646 commit bbd0762

File tree

7 files changed

+49
-7
lines changed

7 files changed

+49
-7
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ bloodhound-cli --edition legacy user -d mydomain.local
7777
bloodhound-cli --edition ce user -d mydomain.local
7878
```
7979

80+
#### Show Version
81+
```bash
82+
bloodhound-cli version
83+
# or
84+
bloodhound-cli --version
85+
```
86+
8087
#### List Group Memberships For A User
8188
```bash
8289
# Resolve recursive memberships (default)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "bloodhound-cli" # The package name as installed via pip (pip install bloodhound-cli)
7-
version = "1.2.3" # Bump: add CE skeleton, --edition, --verbose, rich optional
7+
version = "1.2.4" # Bump: add CE skeleton, --edition, --verbose, rich optional
88
description = "CLI for querying BloodHound data (Legacy Neo4j + CE skeleton)."
99
readme = "README.md"
1010
authors = [

src/bloodhound_cli/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""BloodHound CLI package entrypoint."""
22

3-
__version__ = "1.2.3"
3+
__version__ = "1.2.4"
44
__all__ = ["__version__"]
55

66
# End of package metadata

src/bloodhound_cli/core/logging_utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import structlog
1010

11-
_LOGGER_INITIALISED = False
11+
_logger_initialized = False
1212

1313

1414
def configure_logging(debug: bool = False, json_output: bool = False) -> None:
@@ -18,8 +18,8 @@ def configure_logging(debug: bool = False, json_output: bool = False) -> None:
1818
debug: Whether to emit debug-level events.
1919
json_output: Emit logs as JSON instead of human-readable console output.
2020
"""
21-
global _LOGGER_INITIALISED # pylint: disable=global-statement
22-
if _LOGGER_INITIALISED:
21+
global _logger_initialized # pylint: disable=global-statement
22+
if _logger_initialized:
2323
return
2424

2525
level = logging.DEBUG if debug else logging.INFO
@@ -43,7 +43,7 @@ def configure_logging(debug: bool = False, json_output: bool = False) -> None:
4343
wrapper_class=structlog.make_filtering_bound_logger(level),
4444
cache_logger_on_first_use=True,
4545
)
46-
_LOGGER_INITIALISED = True
46+
_logger_initialized = True
4747

4848

4949
def get_logger(name: str | None = None, **initial_context: Any) -> structlog.BoundLogger:

src/bloodhound_cli/main.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
1717
__package__ = "bloodhound_cli"
1818

19+
from . import __version__ as PACKAGE_VERSION
1920
from .core.factory import create_bloodhound_client
2021
from .core.logging_utils import configure_logging, get_logger
2122
from .core.settings import load_ce_config, load_legacy_config, CONFIG_FILE, CEConfig
@@ -24,6 +25,14 @@
2425
LOGGER = get_logger("cli")
2526

2627

28+
def get_cli_version() -> str:
29+
"""Return the CLI version string."""
30+
return PACKAGE_VERSION or "unknown"
31+
32+
33+
CLI_VERSION = get_cli_version()
34+
35+
2736
def load_config():
2837
"""Load configuration from ~/.bloodhound_config"""
2938
config_path = os.path.expanduser("~/.bloodhound_config")
@@ -222,6 +231,11 @@ def cmd_group(args):
222231
client.close()
223232

224233

234+
def cmd_version(args): # pylint: disable=unused-argument
235+
"""Display the CLI version."""
236+
print(f"bloodhound-cli {CLI_VERSION}")
237+
238+
225239
def register_group_subcommand(subparsers):
226240
"""Register the 'group' command parser."""
227241
group_parser = subparsers.add_parser(
@@ -245,6 +259,12 @@ def register_group_subcommand(subparsers):
245259
group_parser.set_defaults(func=cmd_group)
246260

247261

262+
def register_version_subcommand(subparsers):
263+
"""Register the 'version' command parser."""
264+
version_parser = subparsers.add_parser("version", help="Show CLI version")
265+
version_parser.set_defaults(func=cmd_version)
266+
267+
248268
def cmd_computers(args):
249269
"""List computers in a domain"""
250270
logger = LOGGER.bind(command="computer", edition=args.edition, domain=args.domain)
@@ -653,6 +673,12 @@ def main():
653673
"--verbose", "-v", action="store_true", help="Enable verbose output"
654674
)
655675
parser.add_argument("-o", "--output", help="Output file to save results")
676+
parser.add_argument(
677+
"--version",
678+
action="version",
679+
version=f"%(prog)s {CLI_VERSION}",
680+
help="Show CLI version and exit",
681+
)
656682

657683
# Legacy connection options
658684
parser.add_argument(
@@ -813,6 +839,9 @@ def main():
813839
)
814840
auth_parser.set_defaults(func=cmd_auth)
815841

842+
# Version command
843+
register_version_subcommand(subparsers)
844+
816845
args = parser.parse_args()
817846

818847
configure_logging(debug=args.debug)

tests/unit/test_ce_queries.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,12 @@ def close(self):
736736
assert dummy_client.calls == [("essos.local", "daenerys.targaryen", True)]
737737
assert dummy_client.closed is True
738738

739+
def test_version_command_prints_version(self, capsys):
740+
"""Ensure `bloodhound-cli version` prints the version string."""
741+
cli_main.cmd_version(SimpleNamespace())
742+
captured = capsys.readouterr()
743+
assert captured.out.strip() == f"bloodhound-cli {cli_main.get_cli_version()}"
744+
739745
@pytest.fixture
740746
def mock_ce_client_graph(self):
741747
client = BloodHoundCEClient(

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)