00001 /* Copyright © 2005-2007 Roger Leigh <rleigh@debian.org> 00002 * 00003 * schroot is free software; you can redistribute it and/or modify it 00004 * under the terms of the GNU General Public License as published by 00005 * the Free Software Foundation; either version 2 of the License, or 00006 * (at your option) any later version. 00007 * 00008 * schroot is distributed in the hope that it will be useful, but 00009 * WITHOUT ANY WARRANTY; without even the implied warranty of 00010 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00011 * General Public License for more details. 00012 * 00013 * You should have received a copy of the GNU General Public License 00014 * along with this program; if not, write to the Free Software 00015 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 00016 * MA 02111-1307 USA 00017 * 00018 *********************************************************************/ 00019 00020 #include <config.h> 00021 00022 #include <sbuild/sbuild-i18n.h> 00023 00024 #include "schroot-listmounts-options.h" 00025 00026 #include <cstdlib> 00027 #include <iostream> 00028 00029 #include <boost/format.hpp> 00030 #include <boost/program_options.hpp> 00031 00032 using std::endl; 00033 using boost::format; 00034 using sbuild::_; 00035 namespace opt = boost::program_options; 00036 using namespace schroot_listmounts; 00037 00038 const options::action_type options::ACTION_LISTMOUNTS ("listmounts"); 00039 00040 options::options (): 00041 schroot_base::options(), 00042 mountpoint(), 00043 mount(_("Mount")) 00044 { 00045 } 00046 00047 options::~options () 00048 { 00049 } 00050 00051 void 00052 options::add_options () 00053 { 00054 // Chain up to add basic options. 00055 schroot_base::options::add_options(); 00056 00057 action.add(ACTION_LISTMOUNTS); 00058 action.set_default(ACTION_LISTMOUNTS); 00059 00060 mount.add_options() 00061 ("mountpoint,m", opt::value<std::string>(&this->mountpoint), 00062 _("Mountpoint to check (full path)")); 00063 } 00064 00065 void 00066 options::add_option_groups () 00067 { 00068 // Chain up to add basic option groups. 00069 schroot_base::options::add_option_groups(); 00070 00071 #ifndef BOOST_PROGRAM_OPTIONS_DESCRIPTION_OLD 00072 if (!mount.options().empty()) 00073 #else 00074 if (!mount.primary_keys().empty()) 00075 #endif 00076 { 00077 visible.add(mount); 00078 global.add(mount); 00079 } 00080 } 00081 00082 void 00083 options::check_options () 00084 { 00085 // Chain up to check basic options. 00086 schroot_base::options::check_options(); 00087 00088 if (this->action == ACTION_LISTMOUNTS && 00089 this->mountpoint.empty()) 00090 throw opt::validation_error(_("No mount point specified")); 00091 }