@@ -37,7 +37,7 @@ def main(
3737        The source directory or repository to analyze. 
3838    output : str, optional 
3939        The path where the output file will be written. If not specified, the output will be written 
40-         to a file named `<repo_name>.txt` in the current directory. 
40+         to a file named `<repo_name>.txt` in the current directory. Use '-' to output to stdout.  
4141    max_size : int 
4242        The maximum file size to process, in bytes. Files larger than this size will be ignored. 
4343    exclude_pattern : Tuple[str, ...] 
@@ -63,15 +63,16 @@ async def _async_main(
6363    Analyze a directory or repository and create a text dump of its contents. 
6464
6565    This command analyzes the contents of a specified source directory or repository, applies custom include and 
66-     exclude patterns, and generates a text summary of the analysis which is then written to an output file. 
66+     exclude patterns, and generates a text summary of the analysis which is then written to an output file 
67+     or printed to stdout. 
6768
6869    Parameters 
6970    ---------- 
7071    source : str 
7172        The source directory or repository to analyze. 
7273    output : str, optional 
7374        The path where the output file will be written. If not specified, the output will be written 
74-         to a file named `<repo_name>.txt` in the current directory. 
75+         to a file named `<repo_name>.txt` in the current directory. Use '-' to output to stdout.  
7576    max_size : int 
7677        The maximum file size to process, in bytes. Files larger than this size will be ignored. 
7778    exclude_pattern : Tuple[str, ...] 
@@ -91,16 +92,33 @@ async def _async_main(
9192        exclude_patterns  =  set (exclude_pattern )
9293        include_patterns  =  set (include_pattern )
9394
94-         if  not  output :
95-             output  =  OUTPUT_FILE_NAME 
96-         summary , _ , _  =  await  ingest_async (source , max_size , include_patterns , exclude_patterns , branch , output = output )
95+         output_target  =  output 
96+         if  output  is  None :
97+             output_target  =  OUTPUT_FILE_NAME 
98+             click .echo (f"Analyzing source, output will be written to '{ output_target }  , err = True )
99+         elif  output  ==  "-" :
100+             click .echo ("Analyzing source, preparing output for stdout..." , err = True )
101+         else :
102+             click .echo (f"Analyzing source, output will be written to '{ output_target }  , err = True )
103+ 
104+ 
105+         summary , _ , _  =  await  ingest_async (
106+             source , max_size , include_patterns , exclude_patterns , branch , output = output_target 
107+         )
108+ 
109+         if  output  !=  "-" :
110+             click .echo (f"Analysis complete! Output written to: { output_target }  )
111+             click .echo ("\n Summary:" )
112+             click .echo (summary )
113+         else :
114+             click .echo ("\n --- Summary ---" , err = True )
115+             click .echo (summary , err = True )
116+             click .echo ("--- End Summary ---" , err = True )
117+             click .echo ("Analysis complete! Output sent to stdout." , err = True )
97118
98-         click .echo (f"Analysis complete! Output written to: { output }  )
99-         click .echo ("\n Summary:" )
100-         click .echo (summary )
101119
102120    except  Exception  as  exc :
103-         click .echo (f"Error: { exc }  , err = True )
121+         click .echo (f"Error processing ' { source } ' : { exc }  , err = True )
104122        raise  click .Abort ()
105123
106124
0 commit comments