{"record":{"id":"f6e3c6a32287c1ca","repo":"BigPizzaV3/CodexPlusPlus","slug":"unknown-command-args-command","errorCode":null,"errorMessage":"unknown command: {args.command}","messagePattern":"unknown command: (.+?)","errorType":"exception","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"tools/codex-wechat/codex_wechat.py","lineNumber":835,"sourceCode":"    parser = argparse.ArgumentParser(description=\"Codex WeChat Claw PoC\")\n    sub = parser.add_subparsers(dest=\"command\", required=True)\n\n    run_parser = sub.add_parser(\"run\", help=\"启动 iLink -> codex app-server/exec -> iLink 转发\")\n    run_parser.add_argument(\"--config\", required=True, type=Path, help=\"配置文件路径\")\n\n    login_parser = sub.add_parser(\"login\", help=\"扫码获取 iLink token 并写入配置\")\n    login_parser.add_argument(\"--output\", required=True, type=Path, help=\"要写入的本地配置文件\")\n    login_parser.add_argument(\"--bot-type\", default=\"3\", help=\"iLink bot_type，默认 3\")\n    login_parser.add_argument(\"--timeout\", default=480, type=int, help=\"扫码超时时间，秒\")\n\n    args = parser.parse_args(argv)\n    if args.command == \"run\":\n        poll_loop(load_config(args.config))\n        return 0\n    if args.command == \"login\":\n        qr_login(args.output, args.bot_type, args.timeout)\n        return 0\n    raise SystemExit(f\"unknown command: {args.command}\")\n\n\nif __name__ == \"__main__\":\n    raise SystemExit(main(sys.argv[1:]))\n","sourceCodeStart":817,"sourceCodeEnd":840,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/tools/codex-wechat/codex_wechat.py#L817-L840","documentation":"main dispatches CLI subcommands; only \"run\" and \"login\" are recognized. Although argparse with required subparsers normally rejects unknown commands first, this final raise SystemExit is a defensive fallback: if a command string somehow reaches dispatch without matching either branch, it terminates with `unknown command: {args.command}`.","triggerScenarios":"Invoking the tool with a subcommand other than \"run\" or \"login\" (e.g. `codex-wechat logout`). Raised by `raise SystemExit(f\"unknown command: {args.command}\")` at the end of main, after both the run and login branches fail to match.","commonSituations":"Typo in the subcommand name; calling the script programmatically with a hand-built argv list bypassing argparse; an outdated wrapper/alias pointing at a renamed subcommand; scriptmatic tests passing arbitrary command strings.","solutions":["Run `codex-wechat --help` (or `login --help`, `run --help`) to see valid subcommands and use one of them.","Fix the typo in the invoked subcommand (only \"run\" and \"login\" exist).","If calling main() programmatically, pass argv whose first element is \"run\" or \"login\".","Update any wrapper scripts/aliases that reference removed or renamed subcommands."],"exampleFix":"// before\nraise SystemExit(main([\"logout\"]))\n// after\nraise SystemExit(main([\"login\"]))","handlingStrategy":"validation","validationCode":"VALID_COMMANDS = {\"run\", \"login\"}\nassert argv and argv[0] in VALID_COMMANDS, f\"unknown command: {argv[0] if argv else ''}\"","typeGuard":"def is_valid_command(cmd: str) -> bool:\n    return cmd in (\"run\", \"login\")","tryCatchPattern":null,"preventionTips":["Consult `codex-wechat --help` before invoking unfamiliar subcommands.","Use argparse choices=choices for subparsers so invalid names are rejected with usage output.","Keep wrapper scripts in sync with the subcommand set."],"tags":["cli","invalid-cli-argument","command-not-found"],"backgroundTag":"invalid-cli-argument","analyzedSha":"b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6","analyzedAt":"2026-09-19T23:35:21.129Z","contentChangedAt":"2026-09-19T23:35:21.129Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}