List all available commands.
(api: SerialStudioAPI, args)
| 935 | |
| 936 | |
| 937 | def cmd_list(api: SerialStudioAPI, args) -> int: |
| 938 | """List all available commands.""" |
| 939 | response = api.send_command("api.getCommands") |
| 940 | |
| 941 | if response is None: |
| 942 | print("[ERROR] No response received", file=sys.stderr) |
| 943 | return 1 |
| 944 | |
| 945 | if not response.get("success"): |
| 946 | err = response.get("error", {}) |
| 947 | print(f"[ERROR] {err.get('code')}: {err.get('message')}", file=sys.stderr) |
| 948 | return 1 |
| 949 | |
| 950 | commands = response.get("result", {}).get("commands", []) |
| 951 | |
| 952 | if args.json: |
| 953 | print(json.dumps(commands, indent=2)) |
| 954 | else: |
| 955 | _print_command_list(commands, use_color=COLORS_ENABLED) |
| 956 | |
| 957 | return 0 |
| 958 | |
| 959 | |
| 960 | def cmd_interactive(api: SerialStudioAPI, args) -> int: |
no test coverage detected