on master help sign in
Add proper CLI
a70efaesharkdp
tests/syntax-tests/create_highlighted_versions.py+19−3
@@ -5,6 +5,7 @@ import glob
5import sys
5import sys
6import os.path as path
6import os.path as path
7import os
7import os
8+import argparse
8
9
9
10
10BAT_OPTIONS = [
11BAT_OPTIONS = [
@@ -16,7 +17,7 @@ BAT_OPTIONS = [
16]
17]
17
18
18
19
19−def create_highlighted_versions():
20+def create_highlighted_versions(output_basepath):
20 root = os.path.dirname(os.path.abspath(__file__))
21 root = os.path.dirname(os.path.abspath(__file__))
21
22
22 for source in glob.glob(path.join(root, "source", "*", "*")):
23 for source in glob.glob(path.join(root, "source", "*", "*")):
@@ -28,7 +29,7 @@ def create_highlighted_versions():
28 source_dirname = path.basename(path.dirname(source))
29 source_dirname = path.basename(path.dirname(source))
29 source_filename = path.basename(source)
30 source_filename = path.basename(source)
30
31
31− output_dir = path.join(root, "highlighted", source_dirname)
32+ output_dir = path.join(output_basepath, source_dirname)
32 output_path = path.join(output_dir, source_filename)
33 output_path = path.join(output_dir, source_filename)
33
34
34 os.makedirs(output_dir, exist_ok=True)
35 os.makedirs(output_dir, exist_ok=True)
@@ -55,4 +56,19 @@ def create_highlighted_versions():
55
56
56
57
57if __name__ == "__main__":
58if __name__ == "__main__":
59+ parser = argparse.ArgumentParser(
60+ description="This script creates syntax-highlighted versions of all "
61+ "files in the 'source' directory."
62+ )
63+ parser.add_argument(
64+ "--output",
65+ "-O",
66+ metavar="PATH",
67+ help="Output directory",
68+ required=True,
69+ type=str,
70+ )
71+
72+ args = parser.parse_args()
73+
58− create_highlighted_versions()
74+ create_highlighted_versions(output_basepath=args.output)