Skip to content
Open
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
14 changes: 5 additions & 9 deletions src/apm_cli/commands/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def get(key):
apm config get auto-integrate
apm config get
"""
from ..config import get_config, get_auto_integrate
from ..config import get_auto_integrate

logger = CommandLogger("config get")
if key:
Expand All @@ -162,12 +162,8 @@ def get(key):
)
sys.exit(1)
else:
# Show all config
config_data = get_config()
# Show all user-settable keys with their effective values (including
# defaults). Iterating raw config keys would hide settings that
# have not been written yet (e.g. auto_integrate on a fresh install).
logger.progress("APM Configuration:")
for k, v in config_data.items():
# Map internal keys to user-friendly names
if k == "auto_integrate":
click.echo(f" auto-integrate: {v}")
else:
click.echo(f" {k}: {v}")
click.echo(f" auto-integrate: {get_auto_integrate()}")
14 changes: 7 additions & 7 deletions tests/unit/test_config_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,19 +225,19 @@ def test_get_unknown_key(self):

def test_get_all_config(self):
"""Show all config when no key is provided."""
fake_config = {"auto_integrate": True, "default_client": "vscode"}
with patch("apm_cli.config.get_config", return_value=fake_config):
with patch("apm_cli.config.get_auto_integrate", return_value=True):
result = self.runner.invoke(config, ["get"])
assert result.exit_code == 0
assert "auto-integrate: True" in result.output
# Internal keys must not appear - users cannot set them via apm config set
assert "default_client" not in result.output

def test_get_all_config_unknown_key_passthrough(self):
"""Unknown config keys are shown as-is."""
fake_config = {"some_other_key": "value"}
with patch("apm_cli.config.get_config", return_value=fake_config):
def test_get_all_config_fresh_install(self):
"""auto-integrate is shown even on a fresh install with no key in the file."""
with patch("apm_cli.config.get_auto_integrate", return_value=True):
result = self.runner.invoke(config, ["get"])
assert result.exit_code == 0
assert "some_other_key: value" in result.output
assert "auto-integrate: True" in result.output


class TestAutoIntegrateFunctions:
Expand Down