1 | // $Id: OptionVersion.cc 795 2009-06-30 03:57:27Z 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 "copyright_year.h" |
---|
25 | #include "OptionVersion.h" |
---|
26 | #include "subversion_info.h" |
---|
27 | #include "utility.h" |
---|
28 | |
---|
29 | #include "yat/ColumnStream.h" |
---|
30 | #include "yat/CommandLine.h" |
---|
31 | |
---|
32 | #include <subversion-1/svn_version.h> |
---|
33 | |
---|
34 | #include <apr_version.h> |
---|
35 | |
---|
36 | #include <sstream> |
---|
37 | #include <string> |
---|
38 | |
---|
39 | namespace theplu { |
---|
40 | namespace svndigest { |
---|
41 | |
---|
42 | OptionVersion::OptionVersion(yat::utility::CommandLine& cmd, std::string flag, |
---|
43 | std::string desc, OptionSwitch* const verbose) |
---|
44 | : yat::utility::OptionSwitch(cmd, flag, desc, false), verbose_(verbose) |
---|
45 | { |
---|
46 | } |
---|
47 | |
---|
48 | |
---|
49 | void OptionVersion::do_parse2(std::vector<std::string>::iterator first, |
---|
50 | std::vector<std::string>::iterator last) |
---|
51 | { |
---|
52 | yat::utility::ColumnStream cs(std::cout, 1); |
---|
53 | cs.width(0)=79; |
---|
54 | cs << PACKAGE_NAME << " " << PACKAGE_VERSION; |
---|
55 | bool no_verbose = verbose_ && verbose_->present() && !verbose_->value(); |
---|
56 | if (!no_verbose) { |
---|
57 | cs << " ("; |
---|
58 | if (DEV_BUILD) |
---|
59 | cs << svn_revision() << " "; |
---|
60 | cs << "compiled " << compilation_time() << ", " << compilation_date() |
---|
61 | << ")"; |
---|
62 | } |
---|
63 | cs << "\n\nCopyright (C) " << svn_year() |
---|
64 | << " Jari H\u00E4kkinen and Peter Johansson.\n" |
---|
65 | << "This is free software. You may redistribute copies of it under " |
---|
66 | << "the terms of the GNU General Public License " |
---|
67 | << "<http://www.gnu.org/licenses/gpl.html>.\n" |
---|
68 | << "There is NO WARRANTY; to the extent permitted by law.\n"; |
---|
69 | if (!no_verbose) { |
---|
70 | cs << "\n" |
---|
71 | << "Compiled with libsvn_subr " << SVN_VER_NUM |
---|
72 | << "; using libsvn_subr "; |
---|
73 | const svn_version_t* svn_ver = svn_subr_version(); |
---|
74 | cs << svn_ver->major << '.' << svn_ver->minor << '.' << svn_ver->patch; |
---|
75 | cs << "\n" |
---|
76 | << "Compiled with libapr " << APR_VERSION_STRING |
---|
77 | << "; using libapr "; |
---|
78 | cs << apr_version_string(); |
---|
79 | cs << "\n"; |
---|
80 | } |
---|
81 | exit(0); |
---|
82 | } |
---|
83 | |
---|
84 | }} // of namespace svndigest and theplu |
---|