Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Also use pager for normal queries (but skip paging when output is not to a terminal) #299

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

inkarkat
Copy link

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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant