From 9e81eb28f5ea548a5303d39e3035adbb99b852ce Mon Sep 17 00:00:00 2001 From: saudademjj <128795969+saudademjj@users.noreply.github.com> Date: Tue, 17 Mar 2026 19:59:03 +0800 Subject: [PATCH 1/2] fix: enforce positive token list limits --- src/pumpfun_cli/commands/tokens.py | 10 +++++----- tests/test_commands/test_smoke.py | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/pumpfun_cli/commands/tokens.py b/src/pumpfun_cli/commands/tokens.py index 56e8210..7316406 100644 --- a/src/pumpfun_cli/commands/tokens.py +++ b/src/pumpfun_cli/commands/tokens.py @@ -60,28 +60,28 @@ def _display_tokens(ctx: typer.Context, tokens: list[dict]): @app.command("trending") -def trending(ctx: typer.Context, limit: int = typer.Option(20, "--limit", "-n")): +def trending(ctx: typer.Context, limit: int = typer.Option(20, "--limit", "-n", min=1)): """Top runners + recommended tokens.""" tokens = asyncio.run(get_trending_tokens(limit=limit)) _display_tokens(ctx, tokens) @app.command("new") -def new(ctx: typer.Context, limit: int = typer.Option(20, "--limit", "-n")): +def new(ctx: typer.Context, limit: int = typer.Option(20, "--limit", "-n", min=1)): """Recently launched tokens.""" tokens = asyncio.run(get_new_tokens(limit=limit)) _display_tokens(ctx, tokens) @app.command("graduating") -def graduating(ctx: typer.Context, limit: int = typer.Option(20, "--limit", "-n")): +def graduating(ctx: typer.Context, limit: int = typer.Option(20, "--limit", "-n", min=1)): """Tokens near bonding curve completion.""" tokens = asyncio.run(get_graduating_tokens(limit=limit)) _display_tokens(ctx, tokens) @app.command("recommended") -def recommended(ctx: typer.Context, limit: int = typer.Option(20, "--limit", "-n")): +def recommended(ctx: typer.Context, limit: int = typer.Option(20, "--limit", "-n", min=1)): """Recommended tokens by pump.fun.""" tokens = asyncio.run(get_recommended_tokens(limit=limit)) _display_tokens(ctx, tokens) @@ -91,7 +91,7 @@ def recommended(ctx: typer.Context, limit: int = typer.Option(20, "--limit", "-n def search( ctx: typer.Context, query: str = typer.Argument(...), - limit: int = typer.Option(20, "--limit", "-n"), + limit: int = typer.Option(20, "--limit", "-n", min=1), ): """Search tokens by keyword.""" tokens = asyncio.run(search_tokens(query, limit=limit)) diff --git a/tests/test_commands/test_smoke.py b/tests/test_commands/test_smoke.py index dbc9a35..ad6e73b 100644 --- a/tests/test_commands/test_smoke.py +++ b/tests/test_commands/test_smoke.py @@ -3,6 +3,7 @@ import json import re +import pytest from typer.testing import CliRunner from pumpfun_cli.cli import app @@ -170,3 +171,24 @@ def test_tokens_no_subcommand_shows_help(): """Bare 'tokens' with no subcommand exits 0 and shows help.""" result = runner.invoke(app, ["tokens"]) assert result.exit_code == 0 + + +@pytest.mark.parametrize("limit", ["0", "-1"]) +@pytest.mark.parametrize( + ("subcommand", "extra_args"), + [ + ("trending", []), + ("new", []), + ("graduating", []), + ("recommended", []), + ("search", ["dog"]), + ], +) +def test_tokens_limit_must_be_at_least_one(limit, subcommand, extra_args): + """Token listing commands reject zero and negative limits before execution.""" + result = runner.invoke(app, ["tokens", subcommand, *extra_args, "--limit", limit]) + + assert result.exit_code == 2 + output = _strip_ansi(result.output) + assert "Invalid value for" in output + assert "--limit" in output From dd9d7d42bb2ed94d1079a4d58a6afde64dfaa77f Mon Sep 17 00:00:00 2001 From: saudademjj <128795969+saudademjj@users.noreply.github.com> Date: Tue, 17 Mar 2026 20:12:05 +0800 Subject: [PATCH 2/2] fix: add top alias for token commands --- src/pumpfun_cli/commands/tokens.py | 1 + tests/test_commands/test_smoke.py | 1 + 2 files changed, 2 insertions(+) diff --git a/src/pumpfun_cli/commands/tokens.py b/src/pumpfun_cli/commands/tokens.py index 7316406..b26f42e 100644 --- a/src/pumpfun_cli/commands/tokens.py +++ b/src/pumpfun_cli/commands/tokens.py @@ -81,6 +81,7 @@ def graduating(ctx: typer.Context, limit: int = typer.Option(20, "--limit", "-n" @app.command("recommended") +@app.command("top", hidden=True) def recommended(ctx: typer.Context, limit: int = typer.Option(20, "--limit", "-n", min=1)): """Recommended tokens by pump.fun.""" tokens = asyncio.run(get_recommended_tokens(limit=limit)) diff --git a/tests/test_commands/test_smoke.py b/tests/test_commands/test_smoke.py index ad6e73b..06c3357 100644 --- a/tests/test_commands/test_smoke.py +++ b/tests/test_commands/test_smoke.py @@ -180,6 +180,7 @@ def test_tokens_no_subcommand_shows_help(): ("trending", []), ("new", []), ("graduating", []), + ("top", []), ("recommended", []), ("search", ["dog"]), ],