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

Method parse

ci/compiler/argument_parser.py:118–154  ·  view source on GitHub ↗

Parse arguments and return validated config.

(self, args: Optional[list[str]] = None)

Source from the content-addressed store, hash-verified

116 self.examples_dir = project_root / "examples"
117
118 def parse(self, args: Optional[list[str]] = None) -> CompilationConfig:
119 """Parse arguments and return validated config."""
120 parser = self._create_parser()
121
122 # Parse arguments with intelligent unknown handling
123 try:
124 parsed = parser.parse_intermixed_args(args)
125 unknown: list[str] = []
126 except SystemExit:
127 parsed, unknown = parser.parse_known_args(args)
128
129 # Add unknown non-flag arguments as examples
130 if unknown:
131 extra_examples: list[str] = [
132 arg for arg in unknown if not arg.startswith("-")
133 ]
134 if extra_examples:
135 if (
136 not hasattr(parsed, "positional_examples")
137 or parsed.positional_examples is None
138 ):
139 parsed.positional_examples = []
140 # Type ignore for argparse.Namespace attribute which is dynamically set
141 parsed.positional_examples.extend(extra_examples) # type: ignore[attr-defined]
142
143 # Build configuration
144 config = self._build_config(parsed)
145
146 # Validate
147 errors = config.validate()
148 if errors:
149 print("❌ Configuration validation failed:")
150 for error in errors:
151 print(f" - {error}")
152 sys.exit(1)
153
154 return config
155
156 def _create_parser(self) -> argparse.ArgumentParser:
157 """Create argument parser with all options."""

Callers 1

mainFunction · 0.95

Calls 4

_create_parserMethod · 0.95
_build_configMethod · 0.95
printFunction · 0.50
validateMethod · 0.45

Tested by

no test coverage detected