66"""
77
88import json
9- from argparse import ArgumentParser , Namespace
9+ from argparse import ArgumentParser
1010from pathlib import Path
1111from tempfile import TemporaryDirectory
1212from typing import Any , List , Tuple
@@ -55,67 +55,79 @@ def get_parser() -> ArgumentParser:
5555 :return: ArgumentParser instance
5656 :since: 1.0.0
5757 """
58+
5859 parser = ArgumentParser (description = "Parse flavors.yaml and generate combinations." )
5960
6061 parser .add_argument (
6162 "--commit" ,
6263 default = None ,
6364 help = "Commit hash to fetch flavors.yaml from GitHub. An existing 'flavors.yaml' file will be preferred." ,
6465 )
66+
6567 parser .add_argument (
6668 "--no-arch" ,
6769 action = "store_true" ,
6870 help = "Exclude architecture from the flavor output." ,
6971 )
72+
7073 parser .add_argument (
7174 "--include-only" ,
7275 action = "append" ,
7376 default = [],
7477 help = "Restrict combinations to those matching wildcard patterns (can be specified multiple times)." ,
7578 )
79+
7680 parser .add_argument (
7781 "--exclude" ,
7882 action = "append" ,
7983 default = [],
8084 help = "Exclude combinations based on wildcard patterns (can be specified multiple times)." ,
8185 )
86+
8287 parser .add_argument (
8388 "--build" ,
8489 action = "store_true" ,
8590 help = "Filter combinations to include only those with build enabled." ,
8691 )
92+
8793 parser .add_argument (
8894 "--publish" ,
8995 action = "store_true" ,
9096 help = "Filter combinations to include only those with publish enabled." ,
9197 )
98+
9299 parser .add_argument (
93100 "--test" ,
94101 action = "store_true" ,
95102 help = "Filter combinations to include only those with test enabled." ,
96103 )
104+
97105 parser .add_argument (
98106 "--test-platform" ,
99107 action = "store_true" ,
100108 help = "Filter combinations to include only platforms with test-platform: true." ,
101109 )
110+
102111 parser .add_argument (
103112 "--category" ,
104113 action = "append" ,
105114 default = [],
106115 help = "Filter combinations to include only platforms belonging to the specified categories (can be specified multiple times)." ,
107116 )
117+
108118 parser .add_argument (
109119 "--exclude-category" ,
110120 action = "append" ,
111121 default = [],
112122 help = "Exclude platforms belonging to the specified categories (can be specified multiple times)." ,
113123 )
124+
114125 parser .add_argument (
115126 "--json-by-arch" ,
116127 action = "store_true" ,
117128 help = "Output a JSON dictionary where keys are architectures and values are lists of flavors." ,
118129 )
130+
119131 parser .add_argument (
120132 "--markdown-table-by-platform" ,
121133 action = "store_true" ,
@@ -125,29 +137,15 @@ def get_parser() -> ArgumentParser:
125137 return parser
126138
127139
128- # Parser object for documentation generation
129- parser = get_parser ()
130- parser .prog = "gl-flavors-parse"
131-
132-
133- def parse_args () -> Namespace :
134- """
135- Parses arguments used for main()
136-
137- :return: (object) Parsed argparse.ArgumentParser namespace
138- :since: 0.7.0
139- """
140- return get_parser ().parse_args ()
141-
142-
143140def main () -> None :
144141 """
145142 gl-flavors-parse main()
146143
147144 :since: 0.7.0
148145 """
149146
150- args = parse_args ()
147+ parser = get_parser ()
148+ args = parser .parse_args ()
151149
152150 try :
153151 flavors_data = _get_flavors_file_data (Path (Repository ().root , "flavors.yaml" ))
0 commit comments