monotone

monotone Mtn Source Tree

Root/mt_version.cc

1// Copyright (C) 2004 Nathaniel Smith <njs@pobox.com>
2//
3// This program is made available under the GNU GPL version 2.0 or
4// greater. See the accompanying file COPYING for details.
5//
6// This program is distributed WITHOUT ANY WARRANTY; without even the
7// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8// PURPOSE.
9
10// This is split off into its own file to minimize recompilation time; it is
11// the only .cc file that depends on the revision/full_revision header files,
12// which change constantly.
13
14
15#include "base.hh"
16#include <iostream>
17#include <sstream>
18
19#include <boost/version.hpp>
20#include <boost/config.hpp>
21
22#include "app_state.hh"
23#include "cmd.hh"
24#include "platform.hh"
25#include "mt_version.hh"
26#include "package_revision.h"
27#include "package_full_revision.h"
28#include "sanity.hh"
29
30using std::cout;
31using std::ostringstream;
32using std::string;
33
34CMD_NO_WORKSPACE(version, "version", "", CMD_REF(informative), "",
35 N_("Shows the program version"),
36 "",
37 options::opts::full)
38{
39 N(args.size() == 0,
40 F("no arguments allowed"));
41
42 string version;
43 if (app.opts.full)
44 get_full_version(version);
45 else
46 get_version(version);
47 cout << version << '\n';
48}
49
50void
51get_version(string & out)
52{
53 out = (F("%s (base revision: %s)")
54 % PACKAGE_STRING % string(package_revision_constant)).str();
55}
56
57void
58print_version()
59{
60 string s;
61 get_version(s);
62 cout << s << '\n';
63}
64
65void
66get_full_version(string & out)
67{
68 ostringstream oss;
69 string s;
70 get_version(s);
71 oss << s << '\n';
72 get_system_flavour(s);
73 oss << F("Running on : %s\n"
74 "C++ compiler : %s\n"
75 "C++ standard library: %s\n"
76 "Boost version : %s\n"
77 "Changes since base revision:\n"
78 "%s")
79 % s
80 % BOOST_COMPILER
81 % BOOST_STDLIB
82 % BOOST_LIB_VERSION
83 % string(package_full_revision_constant);
84 out = oss.str();
85}
86
87void
88print_full_version()
89{
90 string s;
91 get_full_version(s);
92 cout << s << '\n';
93}
94
95// Local Variables:
96// mode: C++
97// fill-column: 76
98// c-file-style: "gnu"
99// indent-tabs-mode: nil
100// End:
101// vim: et:sw=2:sts=2:ts=2:cino=>2s,{s,\:s,+s,t0,g0,^-2,e-2,n-2,p2s,(0,=s:

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status