OpenRPC examples upon request (keypress) #2
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
While our abilities are a bit constrained, we may print examples included in OpenRPC data when requested by the user. They will be syntax-highlighted and pretty-printed according to settings. Print "No examples found." if lacking.
The means of making this intermission has already been implemented for libedit in #1, however it remains unresolved for Readline.
Find a key sequence to bind to this action, in the likes of M-? (C-? is the DEL control character and cannot be used).
It is possible and may be desirable to run the pager for this occasion. For
less -R
we'll need to sanitize highlighted output by stripping away ^O^N characters--see degesch. Pager detection is tricky. We can try executingless -R ...
first with a highlightedtmpfile()
and default to${PAGER:-more}
with a strippedtmpfile()
if unsuccessful. Highlighting is an extra stage, so we can just overwrite thetmpfile()
with the raw version of the data andftruncate()
it to the new, shorter size. less(1) doesn't actually warrant reprinting the prompt if it runs on the alternate screen but we don't know up front in the parent process if this will happen. Highlighting will probably require a slight refactor.Even the full schema may be printed but this requires resolving the full tree recursively, isn't as immediately useful, and makes for a new follow-up issue.
This requires at least elementary support of resolving$ref
URIs. Intentionally do not include support for external documents. Only parse#/paths
, in the most naïve way, i.e., check for a leading#/
, split on slashes and try to traverse objects. Doing so should cover most usecases.