source: trunk/yat/utility/OptionHelp.cc @ 985

Last change on this file since 985 was 985, checked in by Peter, 14 years ago

minor bug

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.7 KB
RevLine 
[981]1// $Id: OptionHelp.cc 985 2007-10-22 17:25:37Z peter $
2
3/*
4  Copyright (C) 2007 Peter Johansson
5
6  This file is part of the yat library, http://trac.thep.lu.se/trac/yat
7
8  The yat library 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 2 of the
11  License, or (at your option) any later version.
12
13  The yat library 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 this program; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21  02111-1307, USA.
22*/
23
24#include "OptionHelp.h"
25#include "CommandLine.h"
26
27#include <sstream>
28#include <string>
29
30namespace theplu {
31namespace yat {
32namespace utility {
33
34
35  OptionHelp::OptionHelp(CommandLine& cmd, std::string flag, 
36                         std::string desc)
37    : OptionSwitch(cmd, flag, desc, false), synopsis_("")
38  {
39  }
40
41
42  void OptionHelp::do_parse2(std::vector<std::string>::iterator first, 
43                               std::vector<std::string>::iterator last)
44  {
[985]45    if (usage_.empty()) 
46      std::cout << "Usage: " << cmd().program_name() << " [OPTION]...\n\n";
47    else
48      std::cout << usage_ << "\n"; 
49    std::cout << synopsis_ << "\n";
[982]50    std::cout << cmd() << "\n"; 
[981]51    std::cout << post_cmd_;
52    exit(0);
53  }
54
55
[984]56  std::string& OptionHelp::post_arguments(void)
57  {
58    return post_cmd_;
59  }
60
61
62  std::string& OptionHelp::synopsis(void)
63  {
64    return synopsis_;
65  }
66
67  std::string& OptionHelp::usage(void)
68  {
69    return usage_;
70  }
71
[981]72}}} // of namespace utility, yat, and theplu
Note: See TracBrowser for help on using the repository browser.