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

Commits on Jun 17, 2021

  1. Also use pager for normal queries

    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.
    inkarkat committed Jun 17, 2021
    Configuration menu
    Copy the full SHA
    47e93a8 View commit details
    Browse the repository at this point in the history
  2. Do not do paging if output is not to a terminal

    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.
    inkarkat committed Jun 17, 2021
    Configuration menu
    Copy the full SHA
    cee3efd View commit details
    Browse the repository at this point in the history