From 49526a938f459933a5d61730d70aa71e0149b5c2 Mon Sep 17 00:00:00 2001 From: danmaps Date: Thu, 26 Feb 2026 01:34:16 -0800 Subject: [PATCH] cli: show active map in layer details --- cli/arcgispro_cli/commands/query.py | 11 +++++++++- cli/tests/test_cli.py | 33 ++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/cli/arcgispro_cli/commands/query.py b/cli/arcgispro_cli/commands/query.py index 0686138..c62a23c 100644 --- a/cli/arcgispro_cli/commands/query.py +++ b/cli/arcgispro_cli/commands/query.py @@ -232,7 +232,16 @@ def layer_cmd(name, path, as_json): console.print() console.print(Panel.fit(f"[bold]{layer.get('name', 'Unknown')}[/bold]", title="Layer")) - console.print(f" Map: {layer.get('mapName', '-')}") + map_name = layer.get("mapName", "-") + console.print(f" Map: {map_name}") + + # If map metadata is available, show whether this is the active map + maps = context.get("maps") or [] + if map_name and maps: + m = next((mm for mm in maps if (mm.get("name") or "").lower() == str(map_name).lower()), None) + if m and m.get("isActiveMap") is not None: + console.print(f" Active map: {'Yes' if m.get('isActiveMap') else 'No'}") + console.print(f" Type: {layer.get('layerType', '-')}") console.print(f" Geometry: {layer.get('geometryType', '-') or '-'}") console.print(f" Visible: {'Yes' if layer.get('isVisible') else 'No'}") diff --git a/cli/tests/test_cli.py b/cli/tests/test_cli.py index fefa83b..03b0826 100644 --- a/cli/tests/test_cli.py +++ b/cli/tests/test_cli.py @@ -51,7 +51,38 @@ def test_status_no_folder(): def test_addin_bundled(): """Test that the add-in file is bundled.""" from arcgispro_cli.commands.install import get_addin_path - + addin_path = get_addin_path() assert addin_path.exists(), f"Add-in not found at {addin_path}" assert addin_path.suffix == ".addin" + + +def _write_json(path, obj): + import json + + path.parent.mkdir(parents=True, exist_ok=True) + path.write_text(json.dumps(obj, indent=2), encoding="utf-8") + + +def test_layer_shows_active_map_flag(): + runner = CliRunner() + with runner.isolated_filesystem(): + from pathlib import Path + + _write_json( + Path(".arcgispro/context/maps.json"), + [ + {"name": "Map A", "isActiveMap": True}, + {"name": "Map B", "isActiveMap": False}, + ], + ) + _write_json( + Path(".arcgispro/context/layers.json"), + [ + {"name": "Layer 1", "mapName": "Map A", "isVisible": True}, + ], + ) + + result = runner.invoke(main, ["layer", "Layer 1"]) + assert result.exit_code == 0 + assert "Active map: Yes" in result.output