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 | |
---|
31 | using std::endl; |
---|
32 | using boost::format; |
---|
33 | using sbuild::_; |
---|
34 | namespace opt = boost::program_options; |
---|
35 | using namespace schroot_listmounts; |
---|
36 | |
---|
37 | const options::action_type options::ACTION_LISTMOUNTS ("listmounts"); |
---|
38 | |
---|
39 | options::options (): |
---|
40 | schroot_base::options(), |
---|
41 | mountpoint(), |
---|
42 | mount(_("Mount")) |
---|
43 | { |
---|
44 | } |
---|
45 | |
---|
46 | options::~options () |
---|
47 | { |
---|
48 | } |
---|
49 | |
---|
50 | void |
---|
51 | options::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 | |
---|
64 | void |
---|
65 | options::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 | |
---|
81 | void |
---|
82 | options::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 | } |
---|