| 532 | |
| 533 | |
| 534 | def build_parser() -> argparse.ArgumentParser: |
| 535 | p = argparse.ArgumentParser( |
| 536 | prog="coderlm_cli", |
| 537 | description="CLI wrapper for coderlm-server API", |
| 538 | ) |
| 539 | |
| 540 | sub = p.add_subparsers(dest="cmd", required=True) |
| 541 | |
| 542 | # init |
| 543 | p_init = sub.add_parser("init", help="Create a session for the current project") |
| 544 | p_init.add_argument("--cwd", help="Project directory (default: $PWD)") |
| 545 | p_init.add_argument("--host", default=None, help="Server host (default: 127.0.0.1)") |
| 546 | p_init.add_argument("--port", type=int, default=None, help="Server port (default: 3000)") |
| 547 | p_init.set_defaults(func=cmd_init) |
| 548 | |
| 549 | # status |
| 550 | p_status = sub.add_parser("status", help="Show server and session status") |
| 551 | p_status.add_argument("--host", default=None) |
| 552 | p_status.add_argument("--port", type=int, default=None) |
| 553 | p_status.set_defaults(func=cmd_status) |
| 554 | |
| 555 | # structure |
| 556 | p_struct = sub.add_parser("structure", help="Get project file tree") |
| 557 | p_struct.add_argument("--depth", type=int, default=None, help="Tree depth (0=unlimited)") |
| 558 | p_struct.set_defaults(func=cmd_structure) |
| 559 | |
| 560 | # symbols |
| 561 | p_sym = sub.add_parser("symbols", help="List symbols") |
| 562 | p_sym.add_argument("--kind", help="Filter: function, method, class, struct, enum, trait, interface, constant, type, module") |
| 563 | p_sym.add_argument("--file", help="Filter by file path") |
| 564 | p_sym.add_argument("--limit", type=int, default=None) |
| 565 | p_sym.set_defaults(func=cmd_symbols) |
| 566 | |
| 567 | # search |
| 568 | p_search = sub.add_parser("search", help="Search symbols by name") |
| 569 | p_search.add_argument("query", help="Search term") |
| 570 | p_search.add_argument("--limit", type=int, default=None) |
| 571 | p_search.add_argument("--file", help="Filter results to this file path") |
| 572 | p_search.set_defaults(func=cmd_search) |
| 573 | |
| 574 | # impl |
| 575 | p_impl = sub.add_parser("impl", help="Get full source of a symbol") |
| 576 | p_impl.add_argument("symbol", help="Symbol name") |
| 577 | p_impl.add_argument("--file", required=True, help="File containing the symbol") |
| 578 | p_impl.set_defaults(func=cmd_impl) |
| 579 | |
| 580 | # callers |
| 581 | p_callers = sub.add_parser("callers", help="Find call sites for a symbol") |
| 582 | p_callers.add_argument("symbol", help="Symbol name") |
| 583 | p_callers.add_argument("--file", required=True, help="File containing the symbol") |
| 584 | p_callers.add_argument("--limit", type=int, default=None) |
| 585 | p_callers.set_defaults(func=cmd_callers) |
| 586 | |
| 587 | # tests |
| 588 | p_tests = sub.add_parser("tests", help="Find tests referencing a symbol") |
| 589 | p_tests.add_argument("symbol", help="Symbol name") |
| 590 | p_tests.add_argument("--file", required=True, help="File containing the symbol") |
| 591 | p_tests.add_argument("--limit", type=int, default=None) |