Skip to content

Commit 7179309

Browse files
pyqclaude
andcommitted
fix: separate console streams for proper stdout/stderr routing
Create separate Console instances for regular CLI output (stdout) and error handling (stderr). This ensures: - Logo, help, and normal UI go to stdout (console) - Error tracebacks and error messages go to stderr (err_console) Follows Unix conventions for proper stream separation without mixing normal program output with error diagnostics. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 6d3728f commit 7179309

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/mcpm/cli.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
from mcpm.utils.logging_config import setup_logging
3232
from mcpm.utils.rich_click_config import click, get_header_text
3333

34-
console = Console()
34+
console = Console() # stdout for regular CLI output
35+
err_console = Console(stderr=True) # stderr for errors/tracebacks
3536
client_config_manager = ClientConfigManager()
3637

3738
# Setup Rich logging early - this runs when the module is imported
@@ -53,9 +54,9 @@ def wrapper(*args, **kwargs):
5354
try:
5455
return func(*args, **kwargs)
5556
except Exception:
56-
console.print(Traceback(show_locals=True))
57-
console.print("[bold red]An unexpected error occurred.[/bold red]")
58-
console.print(
57+
err_console.print(Traceback(show_locals=True))
58+
err_console.print("[bold red]An unexpected error occurred.[/bold red]")
59+
err_console.print(
5960
"Please report this issue on our GitHub repository: "
6061
"[link=https://github.com/pathintegral-institute/mcpm.sh/issues]https://github.com/pathintegral-institute/mcpm.sh/issues[/link]"
6162
)

0 commit comments

Comments
 (0)