diff --git a/myagents/commands/upgrade.py b/myagents/commands/upgrade.py index b79354c..9813957 100644 --- a/myagents/commands/upgrade.py +++ b/myagents/commands/upgrade.py @@ -11,11 +11,17 @@ import click @click.command("upgrade") @click.argument("version", required=False) @click.option("--force", is_flag=True, help="Reinstall even if already on that version") +@click.option( + "--beta", + is_flag=True, + help="Forward to xiaohe upgrade --beta", +) @click.option("--user", "user", default=None, hidden=True) @click.option("--password", default=None, hidden=True) def upgrade_cmd( version: str | None, force: bool, + beta: bool, user: str | None, password: str | None, ) -> None: @@ -31,4 +37,6 @@ def upgrade_cmd( cmd.append(version) if force: cmd.append("--force") + if beta: + cmd.append("--beta") raise SystemExit(subprocess.call(cmd)) diff --git a/tests/test_upgrade.py b/tests/test_upgrade.py index f8cc9e8..033a9e7 100644 --- a/tests/test_upgrade.py +++ b/tests/test_upgrade.py @@ -19,6 +19,15 @@ class TestUpgradeCommand: ["/bin/xiaohe", "upgrade", "0.5.1", "--force"] ) + def test_forwards_beta(self) -> None: + with ( + patch.object(up_mod.shutil, "which", return_value="/bin/xiaohe"), + patch.object(up_mod.subprocess, "call", return_value=0) as call, + ): + result = CliRunner().invoke(up_mod.upgrade_cmd, ["--beta"]) + assert result.exit_code == 0 + call.assert_called_once_with(["/bin/xiaohe", "upgrade", "--beta"]) + def test_missing_xiaohe(self) -> None: with patch.object(up_mod.shutil, "which", return_value=None): result = CliRunner().invoke(up_mod.upgrade_cmd, [])