Skip to main content

Module repl

Module repl 

Source
Expand description

futucli repl — 交互式 REPL

特性:

  • 共享一条 FutuClient 长连接,避免每条命令重连网关
  • 复用所有子命令(通过 cli::dispatch
  • rustyline 行编辑:↑↓ 历史、Ctrl-R 反向搜索、Ctrl-D 退出
  • 历史持久化到 ~/.cache/futucli/history(或 $XDG_CACHE_HOME)
  • 订阅推送实时打印且不打断 prompt(ExternalPrinter
  • REPL 专属命令:help / exit / reconnect / subs / unsub

实现要点:rustyline::readline 是阻塞式 API,放进 tokio::task::spawn_blocking 以与 async 命令共存。

Structs§

PrintHandler 🔒
ReplState 🔒
REPL 运行时状态。订阅状态按 Security → 订阅的 SubType 集合 记录, 用 BTreeMap 保证 subs 命令输出稳定可读。

Enums§

PushPrinter 🔒
推送打印器:tty 下走 rustyline ExternalPrinter(不撞 prompt), 非 tty(pipe / 重定向)下降级到 stderr,保证脚本 / 测试里 REPL 仍可用。
ShouldContinue 🔒

Functions§

handle_line 🔒
路由一行输入。REPL 专属命令优先;否则走 clap 解析再转 cli::dispatch
history_file_path 🔒
list_subs 🔒
looks_like_symbol 🔒
print_banner 🔒
print_help 🔒
push_loop 🔒
reconnect 🔒
run
split_sub_args 🔒
sub HK.00700 US.AAPL -t basic,rt → ([“HK.00700”,“US.AAPL”], “basic,rt”)
sub_inline 🔒
sub_type_label 🔒
unsub_inline 🔒

Type Aliases§

SharedPrinter 🔒
包一层 tokio Mutex,跨 task 共享。