From 626348009e74d2ec6e9f500d27f60728b4fc81df Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 2 Apr 2015 11:53:01 +0200 Subject: Add command line option to set verbosity level -v sets it to 1 (shows actual command lines) --verbose sets it to any value in the 0-5 range --- build/b.cxx | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) (limited to 'build/b.cxx') diff --git a/build/b.cxx b/build/b.cxx index d3628d9..c71e6d3 100644 --- a/build/b.cxx +++ b/build/b.cxx @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -36,6 +37,8 @@ #include #include +#include + using namespace std; namespace build @@ -141,13 +144,39 @@ main (int argc, char* argv[]) { tracer trace ("main"); - // Initialize time conversion data that is used by localtime_r(). + cli::argv_scanner scan (argc, argv, true); + options ops (scan); + + // Version. // - tzset (); + if (ops.version ()) + { + cout << "build2 0.0.0" << endl + << "Copyright (c) 2014-2015 Code Synthesis Tools CC" << endl + << "This is free software released under the MIT license. " << endl; + return 0; + } + + // Help. + // + if (ops.help ()) + { + ostream& o (cout); + + o << "Usage: " << argv[0] << " [options] [variables] [buildspec]" << endl + << "Options:" << endl; + + options::print_usage (o); + return 0; + } // Trace verbosity. // - verb = 5; + verb = ops.verbose () > 0 ? ops.verbose () : (ops.v () ? 1 : 0); + + // Initialize time conversion data that is used by localtime_r(). + // + tzset (); // Register modules. // -- cgit v1.1