From b857ea33f36ec6e8d578093f1e8f2b3ba1903e72 Mon Sep 17 00:00:00 2001 From: Tacit Lab Date: Thu, 16 Apr 2026 18:50:14 +0800 Subject: [PATCH] refactor: rename `update` command to `upgrade` - Align CLI verb with pipx/pip terminology (`pipx upgrade`). - Rename internal `self_update` to `self_upgrade` for consistency. - Update README and tests accordingly. - Bump version to 2.0.4. Co-Authored-By: Claude Opus 4.6 --- README.md | 6 +++--- pyproject.toml | 2 +- src/coinhunter/cli.py | 10 +++++----- src/coinhunter/runtime.py | 2 +- tests/test_cli.py | 6 +++--- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 8580f24..77c490b 100644 --- a/README.md +++ b/README.md @@ -91,11 +91,11 @@ coinhunter opportunity portfolio coinhunter opportunity scan coinhunter opportunity scan --symbols BTCUSDT ETHUSDT SOLUSDT -# Self-update -coinhunter update +# Self-upgrade +coinhunter upgrade ``` -`update` will try `pipx upgrade coinhunter` first, and fall back to `pip install --upgrade coinhunter` if pipx is not available. +`upgrade` will try `pipx upgrade coinhunter` first, and fall back to `pip install --upgrade coinhunter` if pipx is not available. ## Architecture diff --git a/pyproject.toml b/pyproject.toml index 285a351..60ca572 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "coinhunter" -version = "2.0.3" +version = "2.0.4" description = "Binance-first trading CLI for balances, market data, opportunity scanning, and execution." readme = "README.md" license = {text = "MIT"} diff --git a/src/coinhunter/cli.py b/src/coinhunter/cli.py index 467abf7..2c960f6 100644 --- a/src/coinhunter/cli.py +++ b/src/coinhunter/cli.py @@ -10,7 +10,7 @@ from . import __version__ from .binance.spot_client import SpotBinanceClient from .binance.um_futures_client import UMFuturesClient from .config import ensure_init_files, get_binance_credentials, load_config -from .runtime import get_runtime_paths, print_output, self_update +from .runtime import get_runtime_paths, print_output, self_upgrade from .services import account_service, market_service, opportunity_service, trade_service EPILOG = """\ @@ -22,7 +22,7 @@ examples: coinhunter trade spot buy BTCUSDT -q 100 -d coinhunter trade futures sell BTCUSDT -q 0.01 -r coinhunter opportunity scan -s BTCUSDT ETHUSDT - coinhunter update + coinhunter upgrade """ @@ -120,7 +120,7 @@ def build_parser() -> argparse.ArgumentParser: scan_parser = opportunity_subparsers.add_parser("scan", help="Scan market for opportunities") scan_parser.add_argument("-s", "--symbols", nargs="*", metavar="SYM", help="Restrict scan to specific symbols") - subparsers.add_parser("update", help="Upgrade coinhunter to the latest version") + subparsers.add_parser("upgrade", help="Upgrade coinhunter to the latest version") return parser @@ -258,8 +258,8 @@ def main(argv: list[str] | None = None) -> int: return 0 parser.error("opportunity requires `portfolio` or `scan`") - if args.command == "update": - print_output(self_update(), agent=args.agent) + if args.command == "upgrade": + print_output(self_upgrade(), agent=args.agent) return 0 parser.error(f"Unsupported command {args.command}") diff --git a/src/coinhunter/runtime.py b/src/coinhunter/runtime.py index d2cea0a..a11309f 100644 --- a/src/coinhunter/runtime.py +++ b/src/coinhunter/runtime.py @@ -58,7 +58,7 @@ def print_json(payload: Any) -> None: print(json.dumps(payload, ensure_ascii=False, indent=2, sort_keys=True, default=json_default)) -def self_update() -> dict[str, Any]: +def self_upgrade() -> dict[str, Any]: if shutil.which("pipx"): cmd = ["pipx", "upgrade", "coinhunter"] else: diff --git a/tests/test_cli.py b/tests/test_cli.py index 908cd3a..5ea903c 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -37,11 +37,11 @@ class CLITestCase(unittest.TestCase): self.assertEqual(result, 1) self.assertIn("error: boom", stderr.getvalue()) - def test_update_dispatches(self): + def test_upgrade_dispatches(self): captured = {} - with patch.object(cli, "self_update", return_value={"command": "pipx upgrade coinhunter", "returncode": 0}), patch.object( + with patch.object(cli, "self_upgrade", return_value={"command": "pipx upgrade coinhunter", "returncode": 0}), patch.object( cli, "print_output", side_effect=lambda payload, **kwargs: captured.setdefault("payload", payload) ): - result = cli.main(["update"]) + result = cli.main(["upgrade"]) self.assertEqual(result, 0) self.assertEqual(captured["payload"]["returncode"], 0)