Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
8 changes: 8 additions & 0 deletions src/pumpfun_cli/commands/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,17 @@ def _config_callback(ctx: typer.Context):
raise SystemExit(0)


KNOWN_KEYS = {"rpc", "keyfile", "priority_fee", "compute_units"}


@app.command("set")
def config_set(ctx: typer.Context, key: str, value: str):
"""Set a config value."""
if key not in KNOWN_KEYS:
error(
f"Unknown config key: {key}",
hint=f"Valid keys: {', '.join(sorted(KNOWN_KEYS))}",
)
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
save_config_value(key, value)
json_mode = ctx.obj.json_mode if ctx.obj else False
if not render({"key": key, "value": value, "status": "saved"}, json_mode):
Expand Down
9 changes: 9 additions & 0 deletions tests/test_commands/test_config_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,12 @@ def test_config_get_json_trailing(tmp_path, monkeypatch):
assert result.exit_code == 0
data = json.loads(result.output)
assert data == {"key": "rpc", "value": "https://example.com"}


def test_config_set_unknown_key(tmp_path, monkeypatch):
"""config set rejects unknown config keys."""
monkeypatch.setenv("XDG_CONFIG_HOME", str(tmp_path))
result = runner.invoke(app, ["config", "set", "rpcc", "https://example.com"])
assert result.exit_code != 0
assert "unknown config key" in result.output.lower()
assert "valid keys" in result.output.lower()
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Loading