()
| 2023 | |
| 2024 | |
| 2025 | def main() -> int: |
| 2026 | parser = build_arg_parser() |
| 2027 | args = parser.parse_args() |
| 2028 | |
| 2029 | source_path = Path(args.source).expanduser().resolve() |
| 2030 | if not source_path.exists(): |
| 2031 | print(f"Error: Source file not found: {source_path}", file=sys.stderr) |
| 2032 | return 1 |
| 2033 | |
| 2034 | if args.output_dir: |
| 2035 | output_dir = Path(args.output_dir).expanduser().resolve() |
| 2036 | else: |
| 2037 | output_dir = source_path.parent / "Code_Structure" |
| 2038 | |
| 2039 | if args.self_check and args.dry_run: |
| 2040 | print("Error: --self-check cannot be used with --dry-run", file=sys.stderr) |
| 2041 | return 2 |
| 2042 | |
| 2043 | layout = load_layout(args) |
| 2044 | |
| 2045 | # If auto-layout requested, do a first-pass analysis to generate layout |
| 2046 | if layout is None: |
| 2047 | print("[AUTO] Running first-pass analysis to generate layout...") |
| 2048 | analyzer = ArchitectureAnalyzer(source_path) |
| 2049 | nodes = analyzer.analyze() |
| 2050 | auto_gen = AutoLayoutGenerator() |
| 2051 | layout = auto_gen.generate(nodes) |
| 2052 | print(f"[AUTO] Generated layout with {len(layout)} modules") |
| 2053 | |
| 2054 | splitter = Splitter( |
| 2055 | source_path=source_path, |
| 2056 | output_dir=output_dir, |
| 2057 | layout=layout, |
| 2058 | dry_run=args.dry_run, |
| 2059 | update_mode=args.update, |
| 2060 | show_tree=args.show_tree, |
| 2061 | dump_layout=args.dump_layout, |
| 2062 | report_name=args.report_name, |
| 2063 | generate_report=not args.no_report, |
| 2064 | ) |
| 2065 | splitter.run() |
| 2066 | |
| 2067 | if args.self_check: |
| 2068 | passed = run_self_check( |
| 2069 | source_path, |
| 2070 | output_dir, |
| 2071 | expect_report=not args.no_report, |
| 2072 | report_name=args.report_name, |
| 2073 | ) |
| 2074 | return 0 if passed else 2 |
| 2075 | |
| 2076 | return 0 |
| 2077 | |
| 2078 | |
| 2079 | if __name__ == "__main__": |
no test coverage detected