summaryrefslogtreecommitdiff
path: root/src/report.h
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-10-28 02:29:22 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-10-28 02:29:22 -0400
commit0872f80d97fd7d4330e8cc4d0b88bbe2170e5eb1 (patch)
tree442c5b44f017b2f852d78e6f565ee16e45039f17 /src/report.h
parent16dbd019bc1d955f083e8f771d00c6a3f9c553ba (diff)
downloadfork-ledger-0872f80d97fd7d4330e8cc4d0b88bbe2170e5eb1.tar.gz
fork-ledger-0872f80d97fd7d4330e8cc4d0b88bbe2170e5eb1.tar.bz2
fork-ledger-0872f80d97fd7d4330e8cc4d0b88bbe2170e5eb1.zip
Make "less" the default pager, similar to Git
Diffstat (limited to 'src/report.h')
-rw-r--r--src/report.h29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/report.h b/src/report.h
index b6133512..6d63a0e9 100644
--- a/src/report.h
+++ b/src/report.h
@@ -629,7 +629,34 @@ public:
});
OPTION(report_t, output_); // -o
- OPTION(report_t, pager_);
+
+ OPTION__
+ (report_t, pager_,
+ CTOR(report_t, pager_) {
+#if 1
+ if (! std::getenv("PAGER")) {
+ bool have_less = false;
+ if (exists(path("/opt/local/bin/less")) ||
+ exists(path("/usr/local/bin/less")) ||
+ exists(path("/usr/bin/less")))
+ have_less = true;
+
+ if (have_less) {
+ on(none, "less");
+ setenv("LESS", "--quit-if-one-screen -R", 0);
+ }
+ }
+#endif
+ }
+ virtual void on_with(const optional<string>& whence, const value_t& text) {
+ string cmd(text.to_string());
+ if (cmd == "" || cmd == "false" || cmd == "off" ||
+ cmd == "none" || cmd == "no" || cmd == "disable")
+ option_t<report_t>::off();
+ else
+ option_t<report_t>::on_with(whence, text);
+ });
+
OPTION(report_t, payee_as_account);
OPTION_(report_t, pending, DO() { // -C