MCPcopy Create free account
hub / github.com/FastLED/FastLED / main

Function main

ci/meson/example_metadata_cache.py:139–225  ·  view source on GitHub ↗

Main entry point for example metadata cache operations.

()

Source from the content-addressed store, hash-verified

137
138
139def main() -> None:
140 """Main entry point for example metadata cache operations."""
141 parser = argparse.ArgumentParser(
142 description="Manage example metadata cache for Meson build system"
143 )
144
145 # Mutually exclusive operation modes
146 group = parser.add_mutually_exclusive_group(required=True)
147 group.add_argument(
148 "--check",
149 action="store_true",
150 help="Check if cache is valid (exit 0 if valid, 1 if invalid)",
151 )
152 group.add_argument(
153 "--update", action="store_true", help="Update cache with new metadata"
154 )
155 group.add_argument(
156 "--invalidate", action="store_true", help="Force invalidate cache"
157 )
158
159 # Positional arguments
160 parser.add_argument(
161 "examples_dir",
162 nargs="?",
163 type=Path,
164 help="Examples directory (required for --check, --update)",
165 )
166 parser.add_argument(
167 "build_dir",
168 nargs="?",
169 type=Path,
170 help="Build directory (required for all operations)",
171 )
172 parser.add_argument(
173 "metadata", nargs="?", type=str, help="Example metadata (required for --update)"
174 )
175
176 args = parser.parse_args()
177
178 # Validate arguments based on operation
179 if args.invalidate:
180 if not args.build_dir:
181 print("Error: --invalidate requires <build_dir>", file=sys.stderr)
182 sys.exit(1)
183
184 cache_file = args.build_dir / CACHE_FILENAME
185 if cache_file.exists():
186 cache_file.unlink()
187 sys.exit(0)
188
189 elif args.check:
190 if not args.examples_dir or not args.build_dir:
191 print("Error: --check requires <examples_dir> <build_dir>", file=sys.stderr)
192 sys.exit(1)
193
194 # Load cached metadata
195 cache: dict[str, str | float] | None = load_cache(args.build_dir)
196 if cache is None:

Callers 1

Calls 6

parse_argsMethod · 0.80
unlinkMethod · 0.80
load_cacheFunction · 0.70
save_cacheFunction · 0.70
printFunction · 0.50

Tested by

no test coverage detected