aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build2/b.cxx35
-rw-r--r--build2/buildfile2
2 files changed, 25 insertions, 12 deletions
diff --git a/build2/b.cxx b/build2/b.cxx
index 96a480a..0cfb6d8 100644
--- a/build2/b.cxx
+++ b/build2/b.cxx
@@ -16,6 +16,7 @@
#include <iostream>
#include <system_error>
+#include <butl/pager>
#include <butl/filesystem>
#include <build2/version>
@@ -41,6 +42,7 @@
#include <build2/b-options>
+using namespace butl;
using namespace std;
#include <build2/config/module>
@@ -63,6 +65,12 @@ main (int argc, char* argv[])
cl::argv_scanner scan (argc, argv, true);
options ops (scan);
+ // Diagnostics verbosity.
+ //
+ verb = ops.verbose_specified ()
+ ? ops.verbose ()
+ : ops.v () ? 2 : ops.q () ? 0 : 1;
+
// Version.
//
if (ops.version ())
@@ -78,21 +86,26 @@ main (int argc, char* argv[])
//
if (ops.help ())
{
- ostream& o (cout);
+ try
+ {
+ pager p ("b help",
+ verb >= 2,
+ ops.pager_specified () ? &ops.pager () : nullptr,
+ &ops.pager_option ());
- o << "Usage: " << argv[0] << " [options] [variables] [buildspec]" << endl
- << "Options:" << endl;
+ print_b_usage (p.stream ());
- options::print_usage (o);
- return 0;
+ // If the pager failed, assume it has issued some diagnostics.
+ //
+ return p.wait () ? 0 : 1;
+ }
+ catch (const system_error& e)
+ {
+ error << "pager failed: " << e.what ();
+ return 1;
+ }
}
- // Diagnostics verbosity.
- //
- verb = ops.verbose_specified ()
- ? ops.verbose ()
- : ops.v () ? 2 : ops.q () ? 0 : 1;
-
// Initialize time conversion data that is used by localtime_r().
//
tzset ();
diff --git a/build2/buildfile b/build2/buildfile
index 412b348..9805378 100644
--- a/build2/buildfile
+++ b/build2/buildfile
@@ -82,7 +82,7 @@ cli.options += -I $src_root --include-with-brackets --include-prefix build2 \
# Usage options.
#
cli.options += --suppress-undocumented --long-usage --ansi-color \
---page-usage 'build2::print_$name$_' --option-length 23
+--page-usage 'build2::print_$name$_' --option-length 20
# Include generated cli files into the distribution.
#