source: trunk/lib/OptionHelp.cc @ 791

Last change on this file since 791 was 727, checked in by Jari Häkkinen, 13 years ago

Changes needed to cleanly compile on g++ 4.3 on SuSE 11 x64.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.7 KB
Line 
1// $Id: OptionHelp.cc 727 2008-12-11 15:02:38Z jari $
2
3/*
4  Copyright (C) 2007 Jari Häkkinen, Peter Johansson
5  Copyright (C) 2008 Jari Häkkinen
6
7  This file is part of svndigest, http://dev.thep.lu.se/svndigest
8
9  svndigest is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License as
11  published by the Free Software Foundation; either version 3 of the
12  License, or (at your option) any later version.
13
14  svndigest is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  General Public License for more details.
18
19  You should have received a copy of the GNU General Public License
20  along with svndigest. If not, see <http://www.gnu.org/licenses/>.
21*/
22
23#include "OptionHelp.h"
24#include "CommandLine.h"
25
26#include <cstdlib>
27#include <sstream>
28#include <string>
29
30namespace theplu {
31namespace svndigest {
32
33  OptionHelp::OptionHelp(CommandLine& cmd, std::string flag, 
34                         std::string desc)
35    : OptionSwitch(cmd, flag, desc, false), synopsis_("")
36  {
37  }
38
39
40  void OptionHelp::do_parse2(std::vector<std::string>::iterator first, 
41                               std::vector<std::string>::iterator last)
42  {
43    if (usage_.empty()) 
44      std::cout << "Usage: " << cmd().program_name() << " [OPTION]...\n\n";
45    else
46      std::cout << usage_ << "\n"; 
47    std::cout << synopsis_ << "\n";
48    std::cout << cmd() << "\n"; 
49    std::cout << post_cmd_;
50    exit(0);
51  }
52
53
54  std::string& OptionHelp::post_arguments(void)
55  {
56    return post_cmd_;
57  }
58
59
60  std::string& OptionHelp::synopsis(void)
61  {
62    return synopsis_;
63  }
64
65  std::string& OptionHelp::usage(void)
66  {
67    return usage_;
68  }
69
70}} // of namespace svndigest and theplu
Note: See TracBrowser for help on using the repository browser.