Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## 5.0.2 (2025-10-23)

- Feature: Added `--version` command-line option to display the current mxdev version. The version is automatically derived from git tags via hatch-vcs during build. Example: `mxdev --version` outputs "mxdev 5.0.1" for releases or "mxdev 5.0.1.dev27+g62877d7" for development versions.
[jensens]
- Fix #70: HTTP-referenced requirements/constraints files are now properly cached and respected in offline mode. Previously, offline mode only skipped VCS operations but still fetched HTTP URLs. Now mxdev caches all HTTP content in `.mxdev_cache/` during online mode and reuses it during offline mode, enabling true offline operation. This fixes the inconsistent behavior where `-o/--offline` didn't prevent all network activity.
[jensens]
- Improvement: Enhanced help text for `-n/--no-fetch`, `-f/--fetch-only`, and `-o/--offline` command-line options to better explain their differences and when to use each one.
Expand Down
11 changes: 11 additions & 0 deletions src/mxdev/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
from .processing import write
from .state import State


try:
from ._version import __version__
except ImportError:
__version__ = "unknown (not installed)"

import argparse
import logging
import sys
Expand Down Expand Up @@ -48,6 +54,11 @@
)
parser.add_argument("-s", "--silent", help="Reduce verbosity", action="store_true")
parser.add_argument("-v", "--verbose", help="Increase verbosity", action="store_true")
parser.add_argument(
"--version",
action="version",
version=f"%(prog)s {__version__}",
)


def supports_unicode() -> bool:
Expand Down
33 changes: 33 additions & 0 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,39 @@ def test_parser_verbose():
assert args.verbose is True


def test_parser_version(capsys):
"""Test --version prints version and exits."""
from mxdev.main import __version__
from mxdev.main import parser

import pytest

with pytest.raises(SystemExit) as exc_info:
parser.parse_args(["--version"])

# Verify clean exit
assert exc_info.value.code == 0

# Verify output contains version string
captured = capsys.readouterr()
assert __version__ in captured.out
assert "." in captured.out # Version has dots (X.Y.Z)


def test_version_format():
"""Test version format is valid."""
from mxdev.main import __version__

# Version should not be the fallback
assert __version__ != "unknown (not installed)"

# Version should contain dots (semantic versioning)
assert "." in __version__

# Version should be a string
assert isinstance(__version__, str)


def test_supports_unicode_with_utf8():
"""Test supports_unicode returns True for UTF-8 encoding."""
from mxdev.main import supports_unicode
Expand Down