Also use pager for normal queries (but skip paging when output is not to a terminal)#299
Open
inkarkat wants to merge 2 commits intochubin:masterfrom
Open
Also use pager for normal queries (but skip paging when output is not to a terminal)#299inkarkat wants to merge 2 commits intochubin:masterfrom
inkarkat wants to merge 2 commits intochubin:masterfrom
Conversation
I don't use --shell very much, rather ad-hoc "cht.sh <query>" in the shell. The paging that is used in shell mode would be helpful there as well, to avoid scrolling back in the terminal when there's long output. The existing do_query() function that is used in shell mode looks like it can be a drop-in replacement for the duplicated curl calls, and with that we get paging for normal queries as well. (And this reuses any set session id as well.) Some initializations need to be moved further up; they still don't run for --help, --mode, and --standalone-install.
We don't want the pager to interfere if the output is redirected to a file, or maybe consumed by another process. For the original do_query() application in shell mode this wasn't so important (nobody would combine interactive shell mode with output redirection), but the pager is now used for normal queries as well. The existing lines variable is reused for disabling the paging (as paging already is skipped if the variable is empty). The overloading with such a control flag has a bit of a smell; on the other hand, we really don't have a number of lines when output is not to a terminal, so it kind-of makes sense.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I don't use
--shellvery much, rather ad-hoccht.sh <query>in the shell. The paging that is used in shell mode would be helpful there as well, to avoid scrolling back in the terminal when there's long output.The existing
do_query()function that is used in shell mode looks like it can be a drop-in replacement for the duplicatedcurlcalls, and with that we get paging for normal queries as well. (And this reuses any set session id as well.)Some initializations need to be moved further up; they still don't run for
--help,--mode, and--standalone-install.