3232from .config import Config , resolve_alias
3333
3434console = Console ()
35+ error_console = Console (stderr = True )
3536
3637
3738SYSTEM_PROMPT = """You are an expert software engineer tasked with analyzing code changes and writing excellent git commit messages.
@@ -490,23 +491,22 @@ async def generate_commit_message(
490491 # Stop progress on error
491492 if "progress" in locals () and progress is not None :
492493 progress .stop ()
493- console .print ("[red]❌ Error: Claude Code CLI not found.[/red]" , file = sys .stderr )
494- console .print (
495- "[yellow]📦 Please install it: npm install -g @anthropic-ai/claude-code[/yellow]" ,
496- file = sys .stderr ,
494+ error_console .print ("[red]❌ Error: Claude Code CLI not found.[/red]" )
495+ error_console .print (
496+ "[yellow]📦 Please install it: npm install -g @anthropic-ai/claude-code[/yellow]"
497497 )
498498 return None
499499 except ProcessError as e :
500500 if "progress" in locals () and progress is not None :
501501 progress .stop ()
502- console .print (f"[red]❌ Process error: { e } [/red]" , file = sys . stderr )
502+ error_console .print (f"[red]❌ Process error: { e } [/red]" )
503503 if e .stderr :
504- console .print (f" stderr: { e .stderr } " , file = sys . stderr )
504+ error_console .print (f" stderr: { e .stderr } " )
505505 return None
506506 except Exception as e :
507507 if "progress" in locals () and progress is not None :
508508 progress .stop ()
509- console .print (f"[red]❌ Unexpected error: { e } [/red]" , file = sys . stderr )
509+ error_console .print (f"[red]❌ Unexpected error: { e } [/red]" )
510510 if verbose :
511511 import traceback
512512
@@ -947,11 +947,11 @@ def main():
947947 )
948948 )
949949 except KeyboardInterrupt :
950- console .print ("\n [yellow]⚠️ Interrupted by user[/yellow]" , file = sys . stderr )
950+ error_console .print ("\n [yellow]⚠️ Interrupted by user[/yellow]" )
951951 sys .exit (130 )
952952
953953 if not commit_message :
954- console .print ("[red]❌ Failed to generate commit message[/red]" , file = sys . stderr )
954+ error_console .print ("[red]❌ Failed to generate commit message[/red]" )
955955 sys .exit (1 )
956956
957957 # Display the generated message with rich formatting
@@ -975,8 +975,8 @@ def main():
975975 pyperclip .copy (commit_message )
976976 console .print ("\n [green]✅ Commit message copied to clipboard![/green]" )
977977 except Exception as e :
978- console .print (
979- f"\n [yellow]⚠️ Failed to copy to clipboard: { e } [/yellow]" , file = sys . stderr
978+ error_console .print (
979+ f"\n [yellow]⚠️ Failed to copy to clipboard: { e } [/yellow]"
980980 )
981981
982982 if args .commit :
@@ -1004,12 +1004,12 @@ def main():
10041004 if result .stdout :
10051005 console .print (result .stdout )
10061006 except subprocess .CalledProcessError as e :
1007- console .print (f"\n [red]❌ Failed to commit: { e } [/red]" , file = sys . stderr )
1007+ error_console .print (f"\n [red]❌ Failed to commit: { e } [/red]" )
10081008 if e .stderr :
1009- console .print (e . stderr , file = sys .stderr )
1009+ error_console .print (e .stderr )
10101010 sys .exit (1 )
10111011 except Exception as e :
1012- console .print (f"\n [red]❌ Unexpected error during commit: { e } [/red]" , file = sys . stderr )
1012+ error_console .print (f"\n [red]❌ Unexpected error during commit: { e } [/red]" )
10131013 sys .exit (1 )
10141014 else :
10151015 # Default: just show the command
0 commit comments