12
12
import sys
13
13
import argparse
14
14
15
- def find_help_files (root , verbose = False ):
15
+ def find_help_files (roots , skip_dirs , verbose = False ):
16
16
# Search for help-*.txt files across the source tree, skipping
17
17
# some directories (e.g., 3rd-party)
18
18
help_files = []
19
- skip_dirs = ['.git' , '3rd-party' ]
20
- for root_dir , dirs , files in os .walk (root ):
21
- for sd in skip_dirs :
22
- if sd in dirs :
23
- dirs .remove (sd )
24
-
25
- for file in files :
26
- if file .startswith ("help-" ) and file .endswith (".txt" ):
27
- full_path = os .path .join (root_dir , file )
28
- help_files .append (full_path )
29
- if verbose :
30
- print (f"Found: { full_path } " )
19
+ for root in roots :
20
+ for root_dir , dirs , files in os .walk (root ):
21
+ for sd in skip_dirs :
22
+ if sd in dirs :
23
+ print (f"Skipping additional dir: { root_dir } /{ sd } " )
24
+ dirs .remove (sd )
25
+
26
+ for file in files :
27
+ if file .startswith ("help-" ) and file .endswith (".txt" ):
28
+ full_path = os .path .join (root_dir , file )
29
+ help_files .append (full_path )
30
+ if verbose :
31
+ print (f"Found: { full_path } " )
32
+
31
33
return help_files
32
34
33
35
def parse_ini_files (file_paths , verbose = False ):
@@ -162,9 +164,14 @@ def generate_c_code(parsed_data):
162
164
163
165
def main ():
164
166
parser = argparse .ArgumentParser (description = "Generate C code from help text INI files." )
165
- parser .add_argument ("--root" ,
167
+ parser .add_argument ("--roots" ,
168
+ nargs = '+' ,
166
169
required = True ,
167
- help = "Root directory to search for help-*.txt files" )
170
+ help = "Space-delimited list of directories to search for help-*.txt files" )
171
+ parser .add_argument ("--skip-dirs" ,
172
+ nargs = '*' ,
173
+ default = ['.git' , '3rd-party' ],
174
+ help = "Space-delimited list of directories to skip traversing" )
168
175
parser .add_argument ("--out" ,
169
176
required = True ,
170
177
help = "Output C file" )
@@ -176,7 +183,7 @@ def main():
176
183
if args .verbose :
177
184
print (f"Searching in: { args .root } " )
178
185
179
- file_paths = find_help_files (args .root , args .verbose )
186
+ file_paths = find_help_files (args .roots , args . skip_dirs , args .verbose )
180
187
parsed_data = parse_ini_files (file_paths , args .verbose )
181
188
c_code = generate_c_code (parsed_data )
182
189
0 commit comments