source: trunk/yat/OptionHelp.cc @ 1556

Last change on this file since 1556 was 1556, checked in by Peter Johansson, 9 years ago

update to latest yat

  • Property svn:eol-style set to native
File size: 1.8 KB
RevLine 
[1556]1// $Id: OptionHelp.cc 2919 2012-12-19 06:54:23Z peter $
[705]2
3/*
[983]4  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
[1556]5  Copyright (C) 2009, 2010, 2012 Peter Johansson
[705]6
[795]7  This file is part of the yat library, http://dev.thep.lu.se/yat
[705]8
[795]9  The yat library is free software; you can redistribute it and/or
[705]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
[795]14  The yat library is distributed in the hope that it will be useful,
[705]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
[795]20  along with yat. If not, see <http://www.gnu.org/licenses/>.
[705]21*/
22
[1556]23#include <config.h>
24
[705]25#include "OptionHelp.h"
26#include "CommandLine.h"
27
[823]28#include <cstdlib>
[824]29#include <iostream>
[705]30#include <string>
31
32namespace theplu {
[795]33namespace yat {
34namespace utility {
[705]35
[795]36
[705]37  OptionHelp::OptionHelp(CommandLine& cmd, std::string flag, 
38                         std::string desc)
39    : OptionSwitch(cmd, flag, desc, false), synopsis_("")
40  {
41  }
42
43
44  void OptionHelp::do_parse2(std::vector<std::string>::iterator first, 
45                               std::vector<std::string>::iterator last)
46  {
47    if (usage_.empty()) 
48      std::cout << "Usage: " << cmd().program_name() << " [OPTION]...\n\n";
49    else
50      std::cout << usage_ << "\n"; 
51    std::cout << synopsis_ << "\n";
52    std::cout << cmd() << "\n"; 
53    std::cout << post_cmd_;
[1058]54    exit(EXIT_SUCCESS);
[705]55  }
56
57
58  std::string& OptionHelp::post_arguments(void)
59  {
60    return post_cmd_;
61  }
62
63
64  std::string& OptionHelp::synopsis(void)
65  {
66    return synopsis_;
67  }
68
69  std::string& OptionHelp::usage(void)
70  {
71    return usage_;
72  }
73
[795]74}}} // of namespace utility, yat, and theplu
Note: See TracBrowser for help on using the repository browser.