source: trunk/debathena/third/schroot/bin/schroot-listmounts/schroot-listmounts-options.cc @ 24167

Revision 24167, 2.1 KB checked in by broder, 15 years ago (diff)
Import schroot upstream into subversion.
Line 
1/* Copyright © 2005-2007  Roger Leigh <rleigh@debian.org>
2 *
3 * schroot is free software: you can redistribute it and/or modify it
4 * under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
7 *
8 * schroot is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 * General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program.  If not, see
15 * <http://www.gnu.org/licenses/>.
16 *
17 *********************************************************************/
18
19#include <config.h>
20
21#include <sbuild/sbuild-i18n.h>
22
23#include "schroot-listmounts-options.h"
24
25#include <cstdlib>
26#include <iostream>
27
28#include <boost/format.hpp>
29#include <boost/program_options.hpp>
30
31using std::endl;
32using boost::format;
33using sbuild::_;
34namespace opt = boost::program_options;
35using namespace schroot_listmounts;
36
37const options::action_type options::ACTION_LISTMOUNTS ("listmounts");
38
39options::options ():
40  schroot_base::options(),
41  mountpoint(),
42  mount(_("Mount"))
43{
44}
45
46options::~options ()
47{
48}
49
50void
51options::add_options ()
52{
53  // Chain up to add basic options.
54  schroot_base::options::add_options();
55
56  action.add(ACTION_LISTMOUNTS);
57  action.set_default(ACTION_LISTMOUNTS);
58
59  mount.add_options()
60    ("mountpoint,m", opt::value<std::string>(&this->mountpoint),
61     _("Mountpoint to check (full path)"));
62}
63
64void
65options::add_option_groups ()
66{
67  // Chain up to add basic option groups.
68  schroot_base::options::add_option_groups();
69
70#ifndef BOOST_PROGRAM_OPTIONS_DESCRIPTION_OLD
71  if (!mount.options().empty())
72#else
73  if (!mount.primary_keys().empty())
74#endif
75    {
76      visible.add(mount);
77      global.add(mount);
78    }
79}
80
81void
82options::check_options ()
83{
84  // Chain up to check basic options.
85  schroot_base::options::check_options();
86
87  if (this->action == ACTION_LISTMOUNTS &&
88      this->mountpoint.empty())
89    throw opt::validation_error(_("No mount point specified"));
90}
Note: See TracBrowser for help on using the repository browser.