|
5 | 5 | # Classes-in-package ascending should favour newer versions of a package (which typically define less classes) and/or selective shades which have picked a few classes to include
|
6 | 6 | # Classes-out-of-package should exclude jars that have shaded this package in, and/or projects distributed as individual modules as well as an `-all` package.
|
7 | 7 |
|
| 8 | +import argparse |
8 | 9 | import re
|
9 | 10 | import sys
|
10 | 11 | import os.path
|
@@ -287,16 +288,26 @@ def adjust_output_jars(jars):
|
287 | 288 | return jars
|
288 | 289 |
|
289 | 290 | if __name__ == '__main__':
|
| 291 | + parser = argparse.ArgumentParser( |
| 292 | + prog='pick-best-jars.py', |
| 293 | + description='Pick the best jars to provide a given package' |
| 294 | + ) |
| 295 | + parser.add_argument('jar_repository_dir', help='Directory containing the jar files to consider') |
| 296 | + parser.add_argument('input_file', help='File containing the packages to consider') |
| 297 | + parser.add_argument('output_file', help='File to write the results to') |
| 298 | + parser.add_argument('-j', '--max-workers', help='Maximum number of worker processes to use', type=int) |
| 299 | + parser.add_argument('--verbose', help='Print verbose output', action='store_true') |
| 300 | + parser.add_argument('--explain', help='Explain the choice of jar for the given package', action='append', default=[]) |
| 301 | + args = parser.parse_args() |
| 302 | + jar_repository_dir = args.jar_repository_dir |
| 303 | + input_file = args.input_file |
| 304 | + output_file = args.output_file |
| 305 | + verbose = args.verbose |
| 306 | + max_workers = args.max_workers |
| 307 | + explain_packages = args.explain |
| 308 | + # replace '.' with '/' in package names |
| 309 | + explain_packages = [p.replace('.', '/') for p in explain_packages] |
290 | 310 |
|
291 |
| - jar_repository_dir = sys.argv[1] |
292 |
| - input_file = sys.argv[2] |
293 |
| - output_file = sys.argv[3] |
294 |
| - |
295 |
| - verbose = any(a == "--verbose" for a in sys.argv) |
296 |
| - max_workers_arg = [a for a in sys.argv if a.startswith("-j")] |
297 |
| - max_workers = int(max_workers_arg[-1][2:]) if len(max_workers_arg) > 0 else None |
298 |
| - explain_arg = [a for a in sys.argv if a.startswith("--explain=")] |
299 |
| - explain_packages = [a[len("--explain="):] for a in explain_arg] |
300 | 311 | if len(explain_packages) != 0:
|
301 | 312 | verbose = True
|
302 | 313 |
|
|
0 commit comments