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

Function main

ci/meson/src_metadata_cache.py:142–233  ·  view source on GitHub ↗

Main entry point for source metadata cache operations.

(argv: list[str] | None = None)

Source from the content-addressed store, hash-verified

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

Callers 1

Calls 6

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

Tested by

no test coverage detected