add an HTTP API
还没有人认领这个 Issue。
评估
调研方向
首先跟踪现有的 /explain 端点,以及它如何解析命令并生成帮助匹配结果。使用建议的 help、cmd 和 matches 字段定义 GET /api/explain?cmd=... 的响应,其中包括重复的帮助文本以及 Unicode 处理等命令变更。完成的标准是:HTTP 端点能够针对 echo -n 示例返回文档中定义的 JSON,并且有合适的集成测试覆盖其行为。
由索引模型根据 Issue 内容生成。
描述
It might be time to add an HTTP API for tools/websites that want to integrate with explainshell (issue #4 is one).
My current thought is to add a GET endpoint at /api/explain with a cmd parameter, similar to /explain. The response could be a JSON that looks something like this:
{
'help' : ['help text 0', 'help text 1', ..],
'cmd' : <parsed command>
'matches' : [{'startindex' : x,
'endindex' : y,
'helpindex' : <index into help array, or -1 if unknown>], [..]]
}
The rationale for not inlining the help text into matches is that there can be duplicates. The reason for including cmd in the response is that it's possible for explainshell to change it, e.g. due to unicode which is not supported yet.
Example:
GET /api/explain?cmd=echo -n
{
'help' : ['display a line of text',
'-n do not output the trailing newline'],
'cmd' : 'echo -n'
'matches' : [{'startindex' : 0, 'endindex' : 4, 'helpindex' : 0},
{'startindex' : 5, 'endindex' : 7, 'helpindex' : 1}]
}
- 主要语言
- Python
- 星标
- 14.3k
- 派生
- 851
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
idank/explainshell 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 75/100
idank/explainshell#367 ·
-
难度 3/5 1-2 天 新手友好度 65/100
idank/explainshell#365 · 2 条评论 ·
-
难度 4/5 3-5 天 新手友好度 35/100
idank/explainshell#354 · 2 条评论 · 4 个 reaction ·
-
难度 3/5 1-2 天 新手友好度 45/100
idank/explainshell#343 ·
-
难度 5/5 一周以上 新手友好度 25/100
idank/explainshell#327 ·
查看 idank/explainshell 的全部 Issue
相似的 Issue
-
needs triage
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
openvinotoolkit/openvino_notebooks#3665 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 86/100
维护者通常 1 天内回复
-
docs
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复
-
benchmark-gap
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复