2929 "--exclude-pattern" ,
3030 "-e" ,
3131 multiple = True ,
32- help = """Patterns to exclude. Handles python's arbitrary subset of Unix
33- shell-style wildcards. See:
34- https://docs.python.org/3/library/fnmatch.html""" ,
32+ help = (
33+ "Patterns to exclude. Handles Python's arbitrary subset of Unix shell-style "
34+ "wildcards. See: https://docs.python.org/3/library/fnmatch.html"
35+ ),
3536)
3637@click .option (
3738 "--include-pattern" ,
3839 "-i" ,
3940 multiple = True ,
40- help = """Patterns to include. Handles python's arbitrary subset of Unix
41- shell-style wildcards. See:
42- https://docs.python.org/3/library/fnmatch.html""" ,
41+ help = (
42+ "Patterns to include. Handles Python's arbitrary subset of Unix shell-style "
43+ "wildcards. See: https://docs.python.org/3/library/fnmatch.html"
44+ ),
4345)
4446@click .option ("--branch" , "-b" , default = None , help = "Branch to clone and ingest" )
4547def main (
@@ -58,21 +60,29 @@ def main(
5860 Parameters
5961 ----------
6062 source : str
61- The source directory or repository to analyze .
63+ A directory path or a Git repository URL .
6264 output : str, optional
63- The path where the output file will be written. If not specified, the output will be written
64- to a file named `<repo_name>.txt` in the current directory.
65+ Output file path. Defaults to `<repo_name>.txt`.
6566 max_size : int
66- The maximum file size to process, in bytes. Files larger than this size will be ignored .
67+ Maximum file size ( in bytes) to consider .
6768 exclude_pattern : Tuple[str, ...]
68- A tuple of patterns to exclude during the analysis. Files matching these patterns will be ignored .
69+ Glob patterns for pruning the file set .
6970 include_pattern : Tuple[str, ...]
70- A tuple of patterns to include during the analysis. Only files matching these patterns will be processed .
71+ Glob patterns for including files in the output .
7172 branch : str, optional
72- The branch to clone (optional ).
73+ Specific branch to ingest (defaults to the repository's default ).
7374 """
74- # Main entry point for the CLI. This function is called when the CLI is run as a script.
75- asyncio .run (_async_main (source , output , max_size , exclude_pattern , include_pattern , branch ))
75+
76+ asyncio .run (
77+ _async_main (
78+ source = source ,
79+ output = output ,
80+ max_size = max_size ,
81+ exclude_pattern = exclude_pattern ,
82+ include_pattern = include_pattern ,
83+ branch = branch ,
84+ )
85+ )
7686
7787
7888async def _async_main (
@@ -92,40 +102,49 @@ async def _async_main(
92102 Parameters
93103 ----------
94104 source : str
95- The source directory or repository to analyze .
105+ A directory path or a Git repository URL .
96106 output : str, optional
97- The path where the output file will be written. If not specified, the output will be written
98- to a file named `<repo_name>.txt` in the current directory.
107+ Output file path. Defaults to `<repo_name>.txt`.
99108 max_size : int
100- The maximum file size to process, in bytes. Files larger than this size will be ignored .
109+ Maximum file size ( in bytes) to consider .
101110 exclude_pattern : Tuple[str, ...]
102- A tuple of patterns to exclude during the analysis. Files matching these patterns will be ignored .
111+ Glob patterns for pruning the file set .
103112 include_pattern : Tuple[str, ...]
104- A tuple of patterns to include during the analysis. Only files matching these patterns will be processed .
113+ Glob patterns for including files in the output .
105114 branch : str, optional
106- The branch to clone (optional ).
115+ Specific branch to ingest (defaults to the repository's default ).
107116
108117 Raises
109118 ------
110119 Abort
111120 If there is an error during the execution of the command, this exception is raised to abort the process.
112121 """
113122 try :
114- # Combine default and custom ignore patterns
123+ # Normalise pattern containers (the ingest layer expects sets)
115124 exclude_patterns = set (exclude_pattern )
116125 include_patterns = set (include_pattern )
117126
118- if not output :
127+ # Choose a default output path if none provided
128+ if output is None :
119129 output = OUTPUT_FILE_NAME
120- summary , _ , _ = await ingest_async (source , max_size , include_patterns , exclude_patterns , branch , output = output )
130+
131+ summary , _ , _ = await ingest_async (
132+ source = source ,
133+ max_file_size = max_size ,
134+ include_patterns = include_patterns ,
135+ exclude_patterns = exclude_patterns ,
136+ branch = branch ,
137+ output = output ,
138+ )
121139
122140 click .echo (f"Analysis complete! Output written to: { output } " )
123141 click .echo ("\n Summary:" )
124142 click .echo (summary )
125143
126144 except Exception as exc :
145+ # Convert any exception into Click.Abort so that exit status is non-zero
127146 click .echo (f"Error: { exc } " , err = True )
128- raise click .Abort ()
147+ raise click .Abort () from exc
129148
130149
131150if __name__ == "__main__" :
0 commit comments