Add legacy tools/cli.py entrypoint to route flag-based toolbelt invocations#24
Conversation
There was a problem hiding this comment.
💡 Codex Review
Lines 14 to 16 in 586cc03
Running this file as documented (python tools/cli.py) fails on a fresh checkout because Python sets sys.path[0] to the tools/ directory, so absolute imports like tools.cli.dispatchers... cannot resolve unless the repo root is on PYTHONPATH. That makes the new entrypoint unusable in the default invocation scenario. Consider adding a small sys.path adjustment to the project root or switching to a -m tools.cli style entrypoint to keep the imports resolvable.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| def main() -> int: | ||
| if _should_use_toolbelt(sys.argv): | ||
| toolbelt_main() | ||
| return 0 |
There was a problem hiding this comment.
Exit code from toolbelt_main is not captured
The return value of toolbelt_main() is discarded, and 0 is always returned regardless of the tool's actual exit status. While this currently works because toolbelt_main() internally calls sys.exit() (making the return 0 unreachable), this is inconsistent with how unified_main() is handled. If toolbelt_main() is ever refactored to return an int instead of calling sys.exit(), exit codes would be silently lost. The code should capture and return the result from toolbelt_main() for consistent behavior.
Motivation
--security-scanby routing them to the toolbelt registry.python tools/cli.pyto act as the SSOT router for CLI usage.Description
tools/cli.pywhich inspectssys.argvand chooses between calling the toolbelt entry (toolbelt_main()) and the unified dispatcher (unified_main()).ToolRegistry.get_all_flags()and explicitly accepts--list,--help, and-has toolbelt-style invocations.mainfunctions.Testing
ToolRegistryand dispatcher entrypoints without edit-time errors.--no-verify, so CI/test runs should be executed in downstream pipelines.Codex Task
Note
Introduces a single entrypoint
tools/cli.pythat delegates CLI handling based on the first argument.ToolRegistry.get_all_flags()and--list,--help,-h) totoolbelt_mainunified_mainfor command-style invocations_should_use_toolbelt(argv)helper and returns appropriate exit status viaSystemExit(main())Written by Cursor Bugbot for commit 586cc03. Configure here.