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

Revision 24167, 2.4 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#include <sbuild/sbuild-util.h>
23
24#include "schroot-mount-options.h"
25
26#include <cstdlib>
27#include <iostream>
28
29#include <boost/format.hpp>
30#include <boost/program_options.hpp>
31
32using std::endl;
33using boost::format;
34using sbuild::_;
35namespace opt = boost::program_options;
36using namespace schroot_mount;
37
38const options::action_type options::ACTION_MOUNT ("mount");
39
40options::options ():
41  schroot_base::options(),
42  dry_run(false),
43  fstab(),
44  mountpoint(),
45  mount(_("Mount"))
46{
47}
48
49options::~options ()
50{
51}
52
53void
54options::add_options ()
55{
56  // Chain up to add basic options.
57  schroot_base::options::add_options();
58
59  action.add(ACTION_MOUNT);
60  action.set_default(ACTION_MOUNT);
61
62
63  mount.add_options()
64    ("dry-run,d",
65     _("Perform a simulation of actions which would be taken"))
66    ("fstab,f", opt::value<std::string>(&this->fstab),
67     _("fstab file to read (full path)"))
68    ("mountpoint,m", opt::value<std::string>(&this->mountpoint),
69     _("Mountpoint to check (full path)"));
70}
71
72void
73options::add_option_groups ()
74{
75  // Chain up to add basic option groups.
76  schroot_base::options::add_option_groups();
77
78#ifndef BOOST_PROGRAM_OPTIONS_DESCRIPTION_OLD
79  if (!mount.options().empty())
80#else
81  if (!mount.primary_keys().empty())
82#endif
83    {
84      visible.add(mount);
85      global.add(mount);
86    }
87}
88
89void
90options::check_options ()
91{
92  // Chain up to check basic options.
93  schroot_base::options::check_options();
94
95  if (vm.count("dry-run"))
96    this->dry_run = true;
97
98  this->mountpoint = sbuild::normalname(this->mountpoint);
99
100  if (this->action == ACTION_MOUNT &&
101      this->mountpoint.empty())
102    throw opt::validation_error(_("No mount point specified"));
103}
Note: See TracBrowser for help on using the repository browser.