Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
14 changes: 0 additions & 14 deletions src/mcpm/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
usage,
)
from mcpm.commands.share import share
from mcpm.migration import V1ConfigDetector, V1ToV2Migrator
from mcpm.utils.logging_config import setup_logging
from mcpm.utils.rich_click_config import click, get_header_text

Expand Down Expand Up @@ -94,19 +93,6 @@ def main(ctx, version, help_flag):
click.rich_click.FOOTER_TEXT = original_footer
return

# Check for v1 configuration and offer migration (even with subcommands)
detector = V1ConfigDetector()
if detector.has_v1_config():
migrator = V1ToV2Migrator()
migration_choice = migrator.show_migration_prompt()
if migration_choice == "migrate":
migrator.migrate_config()
return
elif migration_choice == "start_fresh":
migrator.start_fresh()
# Continue to execute the subcommand
# If "ignore", continue to subcommand without migration

# If no command was invoked, show help with header and footer
if ctx.invoked_subcommand is None:
console.print(get_header_text())
Expand Down
38 changes: 25 additions & 13 deletions src/mcpm/migration/v1_migrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,35 @@ def __init__(self, config_dir: Optional[Path] = None):
def _wait_for_keypress(self, message: str):
"""Wait for any key press (cross-platform)"""
import sys
import termios
import tty

try:
import termios
import tty
except ImportError:
termios = None
tty = None

console.print(message, end="")

try:
# Unix/Linux/macOS
fd = sys.stdin.fileno()
old_settings = termios.tcgetattr(fd)
if termios and tty:
try:
# Unix/Linux/macOS
fd = sys.stdin.fileno()
old_settings = termios.tcgetattr(fd)
try:
tty.setraw(fd)
sys.stdin.read(1)
finally:
termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
except (AttributeError, termios.error, ValueError, OSError):
input()
else:
try:
tty.setraw(sys.stdin.fileno())
sys.stdin.read(1)
finally:
termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
except (ImportError, AttributeError):
# Windows fallback - use input() which requires Enter
input()
import msvcrt
except ImportError:
input()
else:
msvcrt.getch()

console.print() # Add newline after keypress

Expand Down
20 changes: 8 additions & 12 deletions tests/test_global_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,14 @@ def test_list_shows_global_config():

def test_v2_help_shows_global_model():
"""Test that help shows v2.0 global configuration messaging"""
from unittest.mock import patch

# Mock v1 config detection to avoid migration prompt
with patch("mcpm.cli.V1ConfigDetector.has_v1_config", return_value=False):
runner = CliRunner()
result = runner.invoke(main, ["--help"])

assert result.exit_code == 0
assert "global configuration" in result.output.lower()
assert "profile" in result.output.lower()
assert "install" in result.output
assert "run" in result.output
runner = CliRunner()
result = runner.invoke(main, ["--help"])

assert result.exit_code == 0
assert "global configuration" in result.output.lower()
assert "profile" in result.output.lower()
assert "install" in result.output
assert "run" in result.output


def test_deprecated_commands_removed():
Expand Down