add an HTTP API
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 14.2k
- Forks
- 851
- PR merge metrics
- No merged PRs in 30d
Description
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}]
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the existing /explain endpoint and how it parses commands and produces help matches. Define the GET /api/explain?cmd=... response using the proposed help, cmd, and matches fields, including duplicate help text and command changes such as Unicode handling. Done means an HTTP endpoint returns the documented JSON for the echo -n example and suitable integration tests cover its behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100