From e373960236c504a9c4ed83066fad3e3df08ba468 Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Mon, 19 Jun 2017 12:25:54 -0700 Subject: [PATCH] tg: provide global --pager (-p) option Not all commands use a pager for output. It would be incorrect to suddenly unconditionally switch them over to using a pager (even the the pager auto-disables unless the output is to a "terminal"). Instead provide a global --pager (aka -p) option to go with the global --no-pager option just like Git does. For example, tg summary can provide a lot of output really fast now :) if there are a lot of TopGit branches and it's not paged. Using `tg -p summary` solves the problem now. Signed-off-by: Kyle J. McKay --- README | 3 ++- tg.sh | 20 ++++++++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/README b/README index 8a011f5..8fc7c27 100644 --- a/README +++ b/README @@ -784,13 +784,14 @@ USAGE Global options: - ``[-C ]... [-r | -u] [-c =]... [--no-pager]`` + ``[-C ]... [-r | -u] [-c =]... [--[no-]pager]`` -C Change directory to before doing anything more -r Pretend ``topgit.remote`` is set to -u Pretend ``topgit.remote`` is not set -c Pass config option to git, may be repeated --no-pager Disable use of any pager (by both TopGit and Git) + --pager Enable use of a pager (aka ``-p``) --top-bases Show full ``top-bases`` ref prefix and exit --exec-path Show path to subcommand scripts location and exit --help Show brief usage help and exit (aka ``-h``) diff --git a/tg.sh b/tg.sh index 1578fc5..9ab0de7 100644 --- a/tg.sh +++ b/tg.sh @@ -1478,7 +1478,7 @@ do_help() echo "TopGit version $TG_VERSION - A different patch queue manager" echo "Usage: $tgname [-C ] [-r | -u]" \ - "[-c =] [--no-pager] ($cmds) ..." + "[-c =] [--[no-]pager|-p] ($cmds) ..." echo " Or: $tgname help [-w] []" echo "Use \"$tgdisplaydir$tgname help tg\" for overview of TopGit" elif [ -r "$TG_INST_CMDDIR"/tg-$1 -o -r "$TG_INST_SHAREDIR/tg-$1.txt" ] ; then @@ -2262,6 +2262,7 @@ else explicit_dir= gitcdopt= noremote= + forcepager= cmd= while :; do case "$1" in @@ -2297,8 +2298,11 @@ else break;; --no-pager) - GIT_PAGER_IN_USE=1 TG_PAGER_IN_USE=1 && - export GIT_PAGER_IN_USE TG_PAGER_IN_USE + forcepager=0 + shift;; + + --pager|-p) + forcepager=1 shift;; -r) @@ -2369,6 +2373,10 @@ else break;; esac; done + if [ z"$forcepager" = z"0" ]; then + GIT_PAGER_IN_USE=1 TG_PAGER_IN_USE=1 && + export GIT_PAGER_IN_USE TG_PAGER_IN_USE + fi [ -n "$cmd" -o $# -lt 1 ] || { cmd="$1"; shift; } @@ -2523,7 +2531,11 @@ else [ -z "$_use_ref_cache" ] || v_create_ref_cache fullcmd="${tgname:-tg} $cmd $*" - . "$TG_INST_CMDDIR"/tg-$isutil$cmd;; + if [ z"$forcepager" = z"1" ]; then + page '. "$TG_INST_CMDDIR"/tg-$isutil$cmd' "$@" + else + . "$TG_INST_CMDDIR"/tg-$isutil$cmd + fi;; esac fi -- 2.11.4.GIT