CLI: reject invalid player seek and volume values before connecting

未关闭 适合新手
#87 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

  • #90 来自 @bfs2021 —— 已关闭,未合并

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
75/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python
领域
cli

调研方向

从 spotapi player seek 和 spotapi player volume 子命令的 CLI 参数解析开始,阅读 Player.seek() 和 Player.volume() 中现有的范围检查,以保持相同的上下限。添加小型 argparse 类型校验器,拒绝负数的 seek 值以及不在 0-100 范围内的音量,并以退出状态 2 退出,同时保持 0 和 100 有效。当离线测试覆盖负数 seek、低于 0 的音量、高于 100 的音量以及两个边界值时即完成;该 issue 要求在开始前先评论,以避免重复工作。

由索引模型根据 Issue 内容生成。

描述

bug good first issue

Problem

The Python player API correctly rejects negative seek positions and volume values outside 0–100. The CLI currently parses both as unrestricted integers, so obviously invalid input can reach account/session setup before producing an error.

Proposed change

Validate these values during argument parsing:

  • spotapi player seek MILLISECONDS: integer greater than or equal to zero.
  • spotapi player volume PERCENT: integer from zero through 100.

Acceptance criteria

  • Invalid values fail through argparse with a clear range message and exit status 2.
  • Invalid input is rejected before reading account state or opening a Spotify connection.
  • Boundary values 0 and 100 remain valid where applicable.
  • Existing valid commands retain their current behavior.
  • Offline tests cover negative seek, volume below zero, volume above 100, and boundaries.

Scope

Keep validation helpers small and local to the CLI. The existing validation inside Player.seek() and Player.volume() must remain as the library-level safety boundary.

Comment before starting so duplicate work can be avoided.

主要语言
Python
星标
493
派生
40
平均合并
5 分钟
30 天内合并 PR
1

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Aran404/SpotAPI 的其他 Issue

查看 Aran404/SpotAPI 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。