def main( filepath: str, lang: str = "", outdir: str = "", disable_linter: bool = False, check: bool = False, enable_optimize: bool = False, filter_messages: Optional[List[str]] = None, ) -> None: # Parse try: traditional_mode = enable_optimize and not check proto = parse(filepath, traditional_mode=traditional_mode) except ParserError as error: fatal(error.colored()) except IOError as error: fatal(str(error)) # Lint if not disable_linter: lint_warnings = lint(proto) if check: if lint_warnings > 0: fatal() return # Render if not lang: fatal(str(NoLanguageArgument())) if not enable_optimize: if filter_messages: fatal("-F not available in non-optimization mode.") try: render( proto, lang, outdir=outdir, optimization_mode=enable_optimize, optimization_mode_filter_messages=filter_messages, ) except RendererError as error: fatal(error.colored()) except IOError as error: fatal(str(error))
def test_lint_message_field_naming_style() -> None: assert lint(parse(bitproto_filepath("message_field_naming_style.bitproto"))) > 0
def test_lint_enum_contains_0() -> None: assert lint(parse(bitproto_filepath("enum_contains_0.bitproto"))) > 0
def test_lint_enum_naming_style() -> None: assert lint(parse(bitproto_filepath("enum_naming_style.bitproto"))) > 0
def test_lint_constant_naming_style() -> None: assert lint(parse(bitproto_filepath("constant_naming_style.bitproto"))) > 0
def test_lint_definition_indent() -> None: assert lint(parse(bitproto_filepath("definition_indent.bitproto"))) > 0
def test_lint_drone() -> None: assert lint(parse(bitproto_filepath("drone.bitproto"))) == 0