"CLI-Anything: Making ALL Software Agent-Native" -- CLI-Hub: https://clianything.cc/
Python
fix: address 5 fifth-round Copilot review comments
fabio.mantelmacherfc8ba18fbe92
diff --git a/wiremock/agent-harness/cli_anything/wiremock/wiremock_cli.py b/wiremock/agent-harness/cli_anything/wiremock/wiremock_cli.pyindex 034132fd0..ac0274528 100644--- a/wiremock/agent-harness/cli_anything/wiremock/wiremock_cli.py+++ b/wiremock/agent-harness/cli_anything/wiremock/wiremock_cli.py@@ -123,7 +123,15 @@ def stub_get(ctx, stub_id):json_mode = ctx.meta.get("json_mode", False)try:data = StubsManager(client).get(stub_id)- print_json(data)+ if json_mode:+ print_json(data)+ else:+ success(+ f"Stub {data.get('id', stub_id)[:8]}... "+ f"{data.get('request', {}).get('method', '')} "+ f"{data.get('request', {}).get('url', '')}",+ data,+ )except Exception as e:error(str(e), json_mode)@@ -137,7 +145,7 @@ def stub_create(ctx, mapping_json):json_mode = ctx.meta.get("json_mode", False)try:if mapping_json.startswith("@"):- with open(mapping_json[1:]) as f:+ with open(mapping_json[1:], encoding="utf-8") as f:mapping = json.load(f)else:mapping = json.loads(mapping_json)@@ -228,7 +236,7 @@ def stub_import(ctx, file_path):client = ctx.objjson_mode = ctx.meta.get("json_mode", False)try:- with open(file_path) as f:+ with open(file_path, encoding="utf-8") as f:data = json.load(f)result = StubsManager(client).import_stubs(data)if json_mode:@@ -291,7 +299,23 @@ def request_find(ctx, pattern_json):try:pattern = json.loads(pattern_json)data = RequestsLog(client).find(pattern)- print_json(data)+ if json_mode:+ print_json(data)+ else:+ requests_list = data.get("requests", [])+ rows = [+ (+ r.get("request", {}).get("method", ""),+ r.get("request", {}).get("url", ""),+ r.get("responseDefinition", {}).get("status", ""),+ )+ for r in requests_list+ ]+ print_table(+ ["Method", "URL", "Status"],+ rows,+ title=f"Matching requests ({len(requests_list)})",+ )except Exception as e:error(str(e), json_mode)@@ -322,7 +346,22 @@ def request_unmatched(ctx):json_mode = ctx.meta.get("json_mode", False)try:data = RequestsLog(client).unmatched()- print_json(data)+ if json_mode:+ print_json(data)+ else:+ requests_list = data.get("requests", [])+ rows = [+ (+ r.get("request", {}).get("method", ""),+ r.get("request", {}).get("url", ""),+ )+ for r in requests_list+ ]+ print_table(+ ["Method", "URL"],+ rows,+ title=f"Unmatched requests ({len(requests_list)})",+ )except Exception as e:error(str(e), json_mode)diff --git a/wiremock/agent-harness/setup.py b/wiremock/agent-harness/setup.pyindex d56818d93..87a1df681 100644--- a/wiremock/agent-harness/setup.py+++ b/wiremock/agent-harness/setup.py@@ -3,8 +3,12 @@ from setuptools import setup, find_namespace_packagessetup(name="cli-anything-wiremock",version="0.1.0",+ description="CLI harness for WireMock HTTP mock server administration",+ long_description=open("WIREMOCK.md", encoding="utf-8").read(),+ long_description_content_type="text/markdown",packages=find_namespace_packages(include=["cli_anything.*"]),include_package_data=True,+ package_data={"cli_anything.wiremock": ["skills/*.md", "*.md"]},install_requires=["click>=8.0", "requests>=2.28", "rich>=13.0"],entry_points={"console_scripts": [