source: trunk/lib/OptionVersion.cc @ 1060

Last change on this file since 1060 was 1060, checked in by Peter Johansson, 11 years ago

refs #307

Splittin the Parameter class into two separate classes and a base
class holding the common parts. The output of '--help' is not sorted
as before otherwise everything should be the same. The sort will
require some ammendment in yat.

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