feat(ppclock): 倒计时前缀文字位图(clock 拆包/calendar 990 序列)+ CLI --prefix/--show-calendar,102 测试全绿
This commit is contained in:
1 parent
2b01e5f589
commit
f291c61676
7 files changed
+367
-3
No files matched your search
+12
-2
@@ -126,6 +126,9 @@ def build_parser() -> argparse.ArgumentParser:
|
||||
sp = sub.add_parser("countdown", help="倒计时")
|
||||
sp.add_argument("date", nargs="?", help="YYYY-MM-DD")
|
||||
sp.add_argument("--mode", default="clock", choices=["clock", "calendar"])
|
||||
sp.add_argument("--prefix", help="前缀文字(时钟≤8单位/日历≤4字)")
|
||||
sp.add_argument("--show-calendar", action="store_true",
|
||||
help="设置日历中文字并切日历模式一(upload_rili 序列)")
|
||||
sp.add_argument("--off", action="store_true")
|
||||
|
||||
sp = sub.add_parser("sleep", help="休眠时段")
|
||||
@@ -190,11 +193,18 @@ async def _dispatch(args) -> dict | None:
|
||||
if args.off:
|
||||
await C.countdown_off(t)
|
||||
return {"countdown": "off"}
|
||||
if args.show_calendar:
|
||||
if not args.prefix:
|
||||
raise ValueError("--show-calendar 需要 --prefix 提供日历文字")
|
||||
await C.countdown_set(t, None, args.mode, prefix=args.prefix,
|
||||
show_calendar=True)
|
||||
return {"calendar_text": args.prefix}
|
||||
if not args.date:
|
||||
raise ValueError("缺少日期(YYYY-MM-DD)或 --off")
|
||||
d = datetime.date.fromisoformat(args.date)
|
||||
await C.countdown_set(t, d, args.mode)
|
||||
return {"date": d.isoformat(), "mode": args.mode}
|
||||
await C.countdown_set(t, d, args.mode, prefix=args.prefix)
|
||||
return {"date": d.isoformat(), "mode": args.mode,
|
||||
"prefix": args.prefix}
|
||||
if c == "sleep":
|
||||
on = args.on or not args.off
|
||||
await C.sleep(t, on, args.start, args.end)
|
||||
|
||||
Reference in new issue
Block a user