Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions cli/arcgispro_cli/commands/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,13 +241,28 @@ 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]}")
else:
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'}")
Expand Down
33 changes: 32 additions & 1 deletion cli/tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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