Communitygithub.com

cli-anything-wiremock

Python CLI 工具,用於管理 WireMock HTTP 模擬伺服器的管理介面。

cli-anything-wiremock 是什麼?

cli-anything-wiremock 是一個指令列工具,用來包裝 WireMock 的管理 REST API (`/__admin/`),讓開發者與 AI 代理程式能夠從終端機或工具呼叫中管理 HTTP 存根對應、檢查已處理的請求、控制情境狀態,以及錄製真實後端流量。它在整合測試環境中特別有用,協助開發者用可控的模擬回應取代真實的 HTTP 後端。此工具支援 `stub`、`request`、`scenario`、`record`、`settings` 等指令群組,並在代理程式呼叫建議使用 `--json` 參數以取得結構化的 JSON 輸出。透過環境變數 `WIREMOCK_HOST` 與 `WIREMOCK_PORT` 設定連線,可搭配任何支援 WireMock 的測試流程使用。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/HKUDS/CLI-Anything/tree/main/skills/cli-anything-wiremock

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

概述

cli-anything-wiremock 是一個指令列介面,用來包裝 WireMock 管理 REST API (/__admin/)。它允許代理程式與開發者從終端機或代理程式工具呼叫管理 HTTP 存根對應、檢查已處理的請求、控制有狀態的情境,以及錄製真實後端流量。

WireMock 常用於整合測試環境中,以可控的模擬回應取代真實的 HTTP 後端。

指令群組

stub — 管理 HTTP 存根對應

指令描述
stub list列出所有已註冊的存根
stub get <id>根據 UUID 取得特定存根的詳細資訊
stub create <json>透過 JSON 字串建立存根
stub quick M URL S快速建立存根:方法 URL 狀態碼
stub delete <id>根據 UUID 刪除存根
stub reset將所有存根重設為磁碟上的預設值
stub save將記憶體中的存根持久化到磁碟
stub import <file>從 JSON 檔案匯入存根

request — 檢查已處理的請求

指令描述
request list列出最近處理的請求
request find <pattern>尋找符合 JSON 模式的請求
request count <pattern>計算符合 JSON 模式的請求數量
request unmatched列出未匹配任何存根的請求(404)
request reset清除請求日誌

scenario — 有狀態的情境管理

指令描述
scenario list列出所有情境與目前狀態
scenario set N S將情境 NAME 設為 STATE
scenario reset將所有情境重設為初始狀態

record — 從真實後端錄製流量

指令描述
record start <url>啟動代理 + 錄製至 TARGET_URL
record stop停止錄製,回傳捕獲的存根
record status檢查目前是否正在錄製
record snapshot將記憶體中的請求快照為存根

settings — 全域伺服器設定

指令描述
settings get取得目前的 WireMock 全域設定
settings version顯示 WireMock 伺服器版本

頂層指令

指令描述
status檢查 WireMock 是否正在執行
reset完整重設:存根 + 請求 + 情境
shutdown優雅地關閉 WireMock 伺服器

關鍵範例

# 檢查連線
cli-anything-wiremock status

# 使用快速表單建立存根
cli-anything-wiremock stub quick GET /api/users 200 --body '[{"id":1}]'

# 使用完整 JSON 建立存根
cli-anything-wiremock stub create '{
  "request": {"method": "POST", "url": "/api/orders"},
  "response": {"status": 201, "body": "{\"id\":99}"}
}'

# 驗證 POST 請求剛好發生一次
cli-anything-wiremock --json request count '{"method":"POST","url":"/api/orders"}'
# → {"count": 1}

# 情境:推進狀態
cli-anything-wiremock scenario set "cart-flow" "item-added"

# 錄製真實後端
cli-anything-wiremock record start https://api.example.com
# ... 發送請求 ...
cli-anything-wiremock record stop

代理程式指引

在代理程式環境中務必使用 --json

在腳本或代理程式工具呼叫中,請使用 --json 參數。JSON 輸出會根據指令類型而變化(這些是不同的回應類型,並非統一包裝所有回應的封套):

# 資料指令會直接回傳原始的 WireMock API JSON:
cli-anything-wiremock --json stub quick GET /api/hello 200 --body '{"hello":"world"}'
# → {"id": "abc-123", "request": {...}, "response": {...}, ...}

cli-anything-wiremock --json stub list
# → {"mappings": [...], "total": N}

# Void 指令(delete, reset, save)會回傳:
# → {"status": "ok"}

# 錯誤會回傳:
# → {"status": "error", "message": "Connection refused"}

透過環境變數連線

在呼叫任何指令前,先透過環境變數設定連線參數:

export WIREMOCK_HOST=localhost
export WIREMOCK_PORT=8080

測試驗證的工作流程模式

  1. 在執行待測系統前,先設定好存根:
    cli-anything-wiremock --json stub quick POST /api/payment 200 --body '{"success":true}'
    
  2. 執行待測系統。
  3. 驗證互動:
    cli-anything-wiremock --json request count '{"method":"POST","url":"/api/payment"}'
    
  4. 清理:
    cli-anything-wiremock reset
    

錯誤處理

所有錯誤都會導致非零的結束代碼。在 --json 模式下,錯誤會回傳 {"status": "error", "message": "..."}。成功則回傳原始的 WireMock API 回應。

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

cli-anything-adguardhome

>-

cli-anything-anygen

>-

cli-anything-audacity

>-

cli-anything-blender

>-

cli-anything-browser

Browser automation CLI using DOMShell MCP server. Maps Chrome

cli-anything-calibre

>-

cli-anything-ccswitch

CLI interface for CC Switch — manage AI coding tool configurations from the terminal

cli-anything-chromadb

>-

cli-anything-cloudanalyzer

Command-line interface for CloudAnalyzer — Agent-friendly harness for CloudAnalyzer, a QA platform for mapping, localization, and perception outputs. Supports 27 commands across 8 groups: point cloud evaluation, trajectory evaluation, ground segmentation QA, config-driven quality gates, baseline evolution, processing, visualization, and interactive REPL.

cli-anything-cloudcompare

Command-line interface for CloudCompare — Agent-friendly harness for CloudCompare, the open-source 3D point cloud and mesh processing software. Supports 41 commands across 9 groups: project management, session control, point cloud operations (subsample, filter, segment, analyze), mesh operations, distance computation (C2C, C2M), transformations (ICP, matrix), export (LAS/LAZ/PLY/PCD/OBJ/STL/E57), and interactive REPL.

cli-anything-comfyui

>-

cli-anything-dify-workflow

Wrapper for the Dify workflow DSL CLI. Create, inspect, validate, edit, and export Dify workflow files through a CLI-Anything harness.

cli-anything-drawio

>-

cli-anything-eez-studio

Use EEZ Studio from the command line: inspect and modify native .eez-project files, edit LVGL screens/widgets, manage SCPI commands, and invoke the real EEZ Studio backend for LVGL builds.

cli-anything-eth2-quickstart

>-

cli-anything-exa

>-

cli-anything-firefly-iii

Firefly III CLI - Personal finance management via CLI-Anything

cli-anything-freecad

Complete CLI harness for FreeCAD parametric 3D CAD modeler (258 commands). Covers ALL workbenches: Part (29 primitives + boolean + mirror + loft + sweep), Sketcher (26 cmds: geometry + constraints + editing), PartDesign (38 cmds: pad/pocket/groove/fillet/chamfer/patterns/hole/datum), Assembly (11 cmds), Mesh (16 cmds), TechDraw (15 cmds: views + dimensions + PDF/SVG), Draft (33 cmds: 2D shapes + arrays + transforms), FEM (12 cmds), CAM/CNC (10 cmds), Surface (6 cmds), Spreadsheet (7 cmds), Import (13 formats), Export (17 formats), Measure (12 cmds), Materials (21 presets). Headless FreeCAD export to STEP/IGES/STL/OBJ/DXF/PDF/glTF/3MF.

cli-anything-gimp

>-

cli-anything-godot

>-

相關技能