BigPizzaV3/CodexPlusPlus · error · SystemExit
unknown command
Error message
unknown command: {args.command} What it means
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}`.
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.
Example fix
// before raise SystemExit(main(["logout"])) // after raise SystemExit(main(["login"]))
Defensive patterns
Strategy: validation
Validate before calling
VALID_COMMANDS = {"run", "login"}
assert argv and argv[0] in VALID_COMMANDS, f"unknown command: {argv[0] if argv else ''}" Type guard
def is_valid_command(cmd: str) -> bool:
return cmd in ("run", "login") Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.
Related errors
AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19).
Data as JSON: /api/errors/f6e3c6a32287c1ca.
Report an issue: GitHub.
Appendix: source
Thrown at tools/codex-wechat/codex_wechat.py:835
parser = argparse.ArgumentParser(description="Codex WeChat Claw PoC")
sub = parser.add_subparsers(dest="command", required=True)
run_parser = sub.add_parser("run", help="启动 iLink -> codex app-server/exec -> iLink 转发")
run_parser.add_argument("--config", required=True, type=Path, help="配置文件路径")
login_parser = sub.add_parser("login", help="扫码获取 iLink token 并写入配置")
login_parser.add_argument("--output", required=True, type=Path, help="要写入的本地配置文件")
login_parser.add_argument("--bot-type", default="3", help="iLink bot_type,默认 3")
login_parser.add_argument("--timeout", default=480, type=int, help="扫码超时时间,秒")
args = parser.parse_args(argv)
if args.command == "run":
poll_loop(load_config(args.config))
return 0
if args.command == "login":
qr_login(args.output, args.bot_type, args.timeout)
return 0
raise SystemExit(f"unknown command: {args.command}")
if __name__ == "__main__":
raise SystemExit(main(sys.argv[1:]))
View on GitHub (pinned to b1ed92e5e4)