diff --git a/src/pumpfun_cli/commands/config.py b/src/pumpfun_cli/commands/config.py index 4723fc1..6403803 100644 --- a/src/pumpfun_cli/commands/config.py +++ b/src/pumpfun_cli/commands/config.py @@ -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))}", + ) 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): diff --git a/tests/test_commands/test_config_cmd.py b/tests/test_commands/test_config_cmd.py index f2a3b41..fbb7bb4 100644 --- a/tests/test_commands/test_config_cmd.py +++ b/tests/test_commands/test_config_cmd.py @@ -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()