input_handler class decorator to automatically add and create simple input handlers
还没有人认领这个 Issue。
评估
调研方向
Start by tracing the existing input-handler API and the ArgumentParser.add_argument-style entry point referenced in the proposal. Review how simple and custom handlers currently receive command context, parameters, and dynamic list items. Done requires a settled decorator API that supports simple handlers while preserving complex handlers and chaining via next_input.
由索引模型根据 Issue 内容生成。
描述
I was just thinking that most (text) input handlers are fairly simple and provide mostly static values for their (abstract) methods, which makes creation of a separate class rather decoupled from the command's not as transparent as it needs to.
Furthermore, implementing the command's input seems like busy work most of the time and things become especially complicated once you start using multiple handlers and want them to chain using next_input.
I believe a decorator in ArgumentParser.add_argument style could make this API more streamlined while still allowing for the complex case.
API example:
@input_handler("param", kind="text", placeholder="Replace me", validate=lambda _: True)
@input_handler("param2", kind="list", items=list(range(10)))
@input_handler(Param3InputHandler) # name *can* be determined from handler's `name()`
class TestCommand(sublime_plugin.WindowCommand):
def run(self, explicit_param, param, param2, param3, opt_param=None):
pass
Questions
-
Technically, input handlers don't have access to the command instance, the window/view or any of the previous parameters. Especially for the complex case, I'm unsure how to provide this information since you'd use custom handlers mostly in those situations when that information is needed. How to handle this? Just pass
window/viewand a dict of all args to the handler's__init__? -
The same issue also surfaces when the list items you want to provide are dynamic.
-
For a similar reason, I don't think
confirm,cancel, ordescriptionmake much sense to be supplied in the decorator short-hand form. -
Use the
kindparam to distinguish, decide based on anitemsparameter, or use two decorators usetext_input_handlerandlist_input_handler?
- 主要语言
- Python
- 星标
- 56
- 派生
- 4
- 平均合并
- 25 分钟
- 30 天内合并 PR
- 3
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
SublimeText/sublime_lib 的其他 Issue
-
documentation
难度 3/5 1-2 天 新手友好度 35/100
SublimeText/sublime_lib#183 ·
-
documentation
难度 2/5 1-3 小时 新手友好度 38/100
SublimeText/sublime_lib#173 · 1 个 reaction ·
-
难度 5/5 一周以上 新手友好度 35/100
SublimeText/sublime_lib#164 · 1 条评论 ·
-
难度 5/5 一周以上 新手友好度 25/100
SublimeText/sublime_lib#141 · 2 条评论 ·
-
Since 4075, settings are iterable可能已有人在做 @FichteFoll 于 240 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 42/100
SublimeText/sublime_lib#139 · 4 条评论 ·
查看 SublimeText/sublime_lib 的全部 Issue
相似的 Issue
-
tunneld on Windows: Wi-Fi devices are not discovered because uvicorn runs on a ProactorEventLoop未关闭
难度 2/5 1-3 小时 新手友好度 76/100
doronz88/pymobiledevice3#2051 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 90/100
collabnix/awesome-mcp-lists#230 ·
维护者通常 9 天内回复
-
Groc schedules with out of range values pass config validation and fail later when the scheduler is built可能已有人在做 @auraseb 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
-
enhancement
难度 2/5 1-3 小时 新手友好度 72/100
autowarefoundation/autoware_carla_scenario#342 ·
维护者通常 1 天内回复
-
documentation
难度 2/5 1-3 小时 新手友好度 72/100
ianktoo/project-monitor#14 ·