参数错误帮助
❓ 传错参数时 r0capture 不抛栈,而是打印友好帮助。
行为
r0capture 的 ArgParser 重写了 error():
python
def error(self, message):
print("ssl_logger v" + __version__)
print("by " + __author__)
print("Modified by BigfaceCat")
print("Error: " + message)
print()
print(self.format_help().replace("usage:", "Usage:"))
self.exit(0)参数错误时打印版本 + 错误 + 帮助后 exit(0)(非 2)。
示例
bash
python3 r0capture.py -U
# 输出:
# ssl_logger v2.0
# by geffner@google.com (Jason Geffner)
# Modified by BigFaceCat
# Error: the following arguments are required: process
#
# Usage: ...常见参数错误
| 错误 | 原因 |
|---|---|
the following arguments are required: process | 没传进程名/PID |
unrecognized arguments: xxx | 多了未知参数 |
invalid int value: 'abc' | -w 传了非数字 |