source: trunk/lib/OptionVersion.cc @ 909

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

Set the copyright year automatically in svndigest-copy-cache. The year
is stored in a file .release_year and AC_DEFINEd and AC_SUBSTed, so it
can be used in both svndigest-copy-cache and svndigest (via
config.h). No need files lib/copyright_year anymore. The file
.release_year is updated same fashion as copyright_year.cc was
previously. A difference is that a change in .release will cause
configure to be rerun, which is expensive but I think we can live with
the cost since it only happens once a year.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.7 KB
Line 
1// $Id: OptionVersion.cc 909 2009-11-29 22:43:01Z peter $
2
3/*
4  Copyright (C) 2008, 2009 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_LIB
36#include <plplot/plstream.h>
37#endif
38
39#include <sstream>
40#include <string>
41
42namespace theplu {
43namespace svndigest {
44
45  OptionVersion::OptionVersion(yat::utility::CommandLine& cmd, std::string flag, 
46                               std::string desc, OptionSwitch* const verbose)
47    : yat::utility::OptionSwitch(cmd, flag, desc, false), verbose_(verbose)
48  {
49  }
50
51
52  void OptionVersion::do_parse2(std::vector<std::string>::iterator first, 
53                                std::vector<std::string>::iterator last)
54  {
55    yat::utility::ColumnStream cs(std::cout, 1);
56    cs.width(0)=79;
57    cs << PACKAGE_NAME << " " << PACKAGE_VERSION;
58    bool no_verbose = verbose_ && verbose_->present() && !verbose_->value();
59    if (!no_verbose) {
60      cs << " (";
61      if (DEV_BUILD)
62        cs << svn_revision() << " ";
63      cs << "compiled " << compilation_time() << ", " << compilation_date() 
64         << ")";
65    } 
66    cs << "\n\nCopyright (C) " << RELEASE_YEAR
67       << " Jari H\u00E4kkinen and Peter Johansson.\n"
68       << "This is free software. You may redistribute copies of it under "
69       << "the terms of the GNU General Public License "
70       << "<http://www.gnu.org/licenses/gpl.html>.\n"
71       << "There is NO WARRANTY; to the extent permitted by law.\n";
72    if (!no_verbose) {
73      cs << "\n"
74         << "Compiled with libsvn_subr " << SVN_VER_NUM
75         << "; using libsvn_subr ";
76      const svn_version_t* svn_ver = svn_subr_version();
77      cs << svn_ver->major << '.' << svn_ver->minor << '.' << svn_ver->patch;
78      cs << "\n"
79         << "Compiled with libapr " << APR_VERSION_STRING
80         << "; using libapr ";
81      cs << apr_version_string();
82      cs << "\n";
83#ifdef HAVE_LIB
84      cs << "using libplplot ";
85      plstream pls;
86      char* plplot_version;
87      pls.gver(plplot_version);
88      cs << plplot_version << "\n";
89#endif
90    }
91    exit(0);
92  }
93
94}} // of namespace svndigest and theplu
Note: See TracBrowser for help on using the repository browser.