aboutsummaryrefslogtreecommitdiff
path: root/build/b.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-04-02 11:53:01 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-04-02 11:53:01 +0200
commit626348009e74d2ec6e9f500d27f60728b4fc81df (patch)
tree9d56bf2d091abb2a7e99876d1184895e8b6fb4bb /build/b.cxx
parente0de4f26fcf598b4f6beaa2847c4d43a4c761f5b (diff)
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
Diffstat (limited to 'build/b.cxx')
-rw-r--r--build/b.cxx35
1 files changed, 32 insertions, 3 deletions
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 <sstream>
#include <cassert>
#include <typeinfo>
+#include <iostream>
#include <system_error>
#include <build/path>
@@ -36,6 +37,8 @@
#include <build/lexer>
#include <build/parser>
+#include <build/options>
+
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.
//