source: trunk/lib/OptionVersion.cc @ 1058

Last change on this file since 1058 was 1058, checked in by Peter Johansson, 13 years ago

update to latest yat

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.8 KB
Line 
1// $Id: OptionVersion.cc 1058 2010-04-24 16:36:59Z peter $
2
3/*
4  Copyright (C) 2008, 2009, 2010 Peter Johansson
5
6  This file is part of svndigest, http://dev.thep.lu.se/svndigest
7
8  svndigest is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License as
10  published by the Free Software Foundation; either version 3 of the
11  License, or (at your option) any later version.
12
13  svndigest is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  General Public License for more details.
17
18  You should have received a copy of the GNU General Public License
19  along with svndigest. If not, see <http://www.gnu.org/licenses/>.
20*/
21
22#include <config.h>
23
24#include "OptionVersion.h"
25#include "subversion_info.h"
26#include "utility.h"
27
28#include "yat/ColumnStream.h"
29#include "yat/CommandLine.h"
30
31#include <subversion-1/svn_version.h>
32
33#include <apr_version.h>
34
35#ifdef HAVE_PLPLOT
36#include <plplot/plstream.h>
37#endif
38
39#include <cstdlib>
40#include <iostream>
41#include <sstream>
42#include <string>
43
44namespace theplu {
45namespace svndigest {
46
47  OptionVersion::OptionVersion(yat::utility::CommandLine& cmd, std::string flag, 
48                               std::string desc, OptionSwitch* const verbose)
49    : yat::utility::OptionSwitch(cmd, flag, desc, false), verbose_(verbose)
50  {
51  }
52
53
54  void OptionVersion::do_parse2(std::vector<std::string>::iterator first, 
55                                std::vector<std::string>::iterator last)
56  {
57    yat::utility::ColumnStream cs(std::cout, 1);
58    cs.width(0)=79;
59    cs << PACKAGE_NAME << " " << PACKAGE_VERSION;
60    bool no_verbose = verbose_ && verbose_->present() && !verbose_->value();
61    if (!no_verbose) {
62      cs << " (";
63      if (DEV_BUILD)
64        cs << svn_revision() << " ";
65      cs << "compiled " << compilation_time() << ", " << compilation_date() 
66         << ")";
67    } 
68    cs << "\n\nCopyright (C) " << RELEASE_YEAR
69       << " Jari H\u00E4kkinen and Peter Johansson.\n"
70       << "This is free software. You may redistribute copies of it under "
71       << "the terms of the GNU General Public License "
72       << "<http://www.gnu.org/licenses/gpl.html>.\n"
73       << "There is NO WARRANTY; to the extent permitted by law.\n";
74    if (!no_verbose) {
75      cs << "\n"
76         << "Compiled with libsvn_subr " << SVN_VER_NUM
77         << "; using libsvn_subr ";
78      const svn_version_t* svn_ver = svn_subr_version();
79      cs << svn_ver->major << '.' << svn_ver->minor << '.' << svn_ver->patch;
80      cs << "\n"
81         << "Compiled with libapr " << APR_VERSION_STRING
82         << "; using libapr ";
83      cs << apr_version_string();
84      cs << "\n";
85#ifdef HAVE_PLPLOT
86      cs << "using libplplot ";
87      plstream pls;
88      char* plplot_version = new char[32];
89      pls.gver(plplot_version);
90      cs << plplot_version << "\n";
91      delete [] plplot_version;
92#endif
93    }
94    exit(EXIT_SUCCESS);
95  }
96
97}} // of namespace svndigest and theplu
Note: See TracBrowser for help on using the repository browser.