diff --git a/cli/arcgispro_cli/commands/query.py b/cli/arcgispro_cli/commands/query.py index df82579..2567cb0 100644 --- a/cli/arcgispro_cli/commands/query.py +++ b/cli/arcgispro_cli/commands/query.py @@ -241,6 +241,7 @@ def layer_cmd(name, path, as_json): console.print() console.print(Panel.fit(f"[bold]{layer.get('name', 'Unknown')}[/bold]", title="Layer")) + # Map membership (a layer can appear in multiple maps) if map_names: if len(map_names) == 1: console.print(f" Map: {map_names[0]}") @@ -248,6 +249,20 @@ def layer_cmd(name, path, as_json): console.print(f" Maps: {', '.join(map_names)}") else: console.print(" Map: -") + + # If map metadata is available, show which of the above maps are active + maps = context.get("maps") or [] + if map_names and maps: + active_names = [] + for mn in map_names: + m = next((mm for mm in maps if (mm.get("name") or "").lower() == str(mn).lower()), None) + if m and m.get("isActiveMap") is True: + active_names.append(mn) + + if len(map_names) == 1: + console.print(f" Active map: {'Yes' if active_names else 'No'}") + elif active_names: + console.print(f" Active maps: {', '.join(active_names)}") 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 14d0523..7da75fd 100644 --- a/cli/tests/test_cli.py +++ b/cli/tests/test_cli.py @@ -52,7 +52,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