MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / cmd_list

Function cmd_list

examples/API Test/test_api.py:937–957  ·  view source on GitHub ↗

List all available commands.

(api: SerialStudioAPI, args)

Source from the content-addressed store, hash-verified

935
936
937def 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
960def cmd_interactive(api: SerialStudioAPI, args) -> int:

Callers 1

mainFunction · 0.85

Calls 3

_print_command_listFunction · 0.85
send_commandMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected