1212import sys
1313import argparse
1414
15- def find_help_files (root , verbose = False ):
15+ def find_help_files (roots , skip_dirs , verbose = False ):
1616 # Search for help-*.txt files across the source tree, skipping
1717 # some directories (e.g., 3rd-party)
1818 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+
3133 return help_files
3234
3335def parse_ini_files (file_paths , verbose = False ):
@@ -162,9 +164,14 @@ def generate_c_code(parsed_data):
162164
163165def main ():
164166 parser = argparse .ArgumentParser (description = "Generate C code from help text INI files." )
165- parser .add_argument ("--root" ,
167+ parser .add_argument ("--roots" ,
168+ nargs = '+' ,
166169 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" )
168175 parser .add_argument ("--out" ,
169176 required = True ,
170177 help = "Output C file" )
@@ -176,7 +183,7 @@ def main():
176183 if args .verbose :
177184 print (f"Searching in: { args .root } " )
178185
179- file_paths = find_help_files (args .root , args .verbose )
186+ file_paths = find_help_files (args .roots , args . skip_dirs , args .verbose )
180187 parsed_data = parse_ini_files (file_paths , args .verbose )
181188 c_code = generate_c_code (parsed_data )
182189
0 commit comments