()
| 1268 | |
| 1269 | |
| 1270 | def main(): |
| 1271 | parser = argparse.ArgumentParser( |
| 1272 | description="Serial Studio API Client & Test Suite", |
| 1273 | formatter_class=argparse.RawDescriptionHelpFormatter, |
| 1274 | epilog=""" |
| 1275 | Examples: |
| 1276 | %(prog)s send io.getStatus # Send a command |
| 1277 | %(prog)s send io.uart.setBaudRate -p baudRate=115200 # With key=value params |
| 1278 | %(prog)s send io.uart.setDtrEnabled -p dtrEnabled=true # Boolean param |
| 1279 | %(prog)s list # List commands |
| 1280 | %(prog)s interactive # Interactive mode |
| 1281 | %(prog)s monitor --interval 500 # Live monitor |
| 1282 | %(prog)s batch commands.json # Batch from file |
| 1283 | %(prog)s test --verbose # Run smoke tests |
| 1284 | """, |
| 1285 | ) |
| 1286 | |
| 1287 | parser.add_argument( |
| 1288 | "--host", default=DEFAULT_HOST, help=f"Server host (default: {DEFAULT_HOST})" |
| 1289 | ) |
| 1290 | parser.add_argument( |
| 1291 | "--port", |
| 1292 | type=int, |
| 1293 | default=DEFAULT_PORT, |
| 1294 | help=f"Server port (default: {DEFAULT_PORT})", |
| 1295 | ) |
| 1296 | parser.add_argument( |
| 1297 | "--verbose", "-v", action="store_true", help="Enable verbose output" |
| 1298 | ) |
| 1299 | parser.add_argument( |
| 1300 | "--json", "-j", action="store_true", help="Output raw JSON (for scripting)" |
| 1301 | ) |
| 1302 | |
| 1303 | subparsers = parser.add_subparsers(dest="mode", help="Operation mode") |
| 1304 | |
| 1305 | send_parser = subparsers.add_parser("send", help="Send a single command") |
| 1306 | send_parser.add_argument("command", help="Command to send (e.g., io.getStatus)") |
| 1307 | send_parser.add_argument( |
| 1308 | "--params", |
| 1309 | "-p", |
| 1310 | nargs="+", |
| 1311 | metavar="PARAM", |
| 1312 | help="Parameters as key=value pairs or JSON. " |
| 1313 | "Examples: baudRate=115200 or '{\"baudRate\": 115200}'", |
| 1314 | ) |
| 1315 | |
| 1316 | batch_parser = subparsers.add_parser( |
| 1317 | "batch", help="Send batch commands from JSON file" |
| 1318 | ) |
| 1319 | batch_parser.add_argument("file", help="JSON file containing commands") |
| 1320 | |
| 1321 | subparsers.add_parser("list", help="List all available commands") |
| 1322 | |
| 1323 | subparsers.add_parser( |
| 1324 | "interactive", aliases=["i", "repl"], help="Interactive REPL mode" |
| 1325 | ) |
| 1326 | |
| 1327 | monitor_parser = subparsers.add_parser( |
no test coverage detected