Skip to content

Commit 0ec6b6a

Browse files
refactor(cli): use ResultReporter in handle_env_python_add_hatch_mcp
1 parent df64898 commit 0ec6b6a

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

hatch/cli/cli_env.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,12 +419,21 @@ def handle_env_python_add_hatch_mcp(args: Namespace) -> int:
419419
env_manager: "HatchEnvironmentManager" = args.env_manager
420420
hatch_env = getattr(args, "hatch_env", None)
421421
tag = getattr(args, "tag", None)
422+
dry_run = getattr(args, "dry_run", False)
422423

423424
env_name = hatch_env or env_manager.get_current_environment()
424425

426+
# Create reporter for unified output
427+
reporter = ResultReporter("hatch env python add-hatch-mcp", dry_run=dry_run)
428+
reporter.add(ConsequenceType.INSTALL, f"hatch_mcp_server wrapper in '{env_name}'")
429+
430+
if dry_run:
431+
reporter.report_result()
432+
return EXIT_SUCCESS
433+
425434
if env_manager.install_mcp_server(env_name, tag):
426-
print(f"hatch_mcp_server wrapper installed successfully in environment: {env_name}")
435+
reporter.report_result()
427436
return EXIT_SUCCESS
428437
else:
429-
print(f"Failed to install hatch_mcp_server wrapper in environment: {env_name}")
438+
print(f"[ERROR] Failed to install hatch_mcp_server wrapper in environment: {env_name}")
430439
return EXIT_ERROR

0 commit comments

Comments
 (0)