schroot-listmounts-options.cc

Go to the documentation of this file.
00001 /* Copyright © 2005-2006  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 namespace opt = boost::program_options;
00035 using namespace schroot_listmounts;
00036 
00037 options::options ():
00038   schroot_base::options(),
00039   action(ACTION_LISTMOUNTS),
00040   mountpoint(),
00041   mount(_("Mount"))
00042 {
00043 }
00044 
00045 options::~options ()
00046 {
00047 }
00048 
00049 void
00050 options::add_options ()
00051 {
00052   schroot_base::options::add_options();
00053 
00054   mount.add_options()
00055     ("mountpoint,m", opt::value<std::string>(&this->mountpoint),
00056      _("Mountpoint to check (full path)"));
00057 }
00058 
00059 void
00060 options::add_option_groups ()
00061 {
00062   schroot_base::options::add_option_groups();
00063 
00064 #ifndef BOOST_PROGRAM_OPTIONS_DESCRIPTION_OLD
00065   if (!mount.options().empty())
00066 #else
00067   if (!mount.primary_keys().empty())
00068 #endif
00069     {
00070       visible.add(mount);
00071       global.add(mount);
00072     }
00073 }
00074 
00075 void
00076 options::check_options ()
00077 {
00078   schroot_base::options::check_options();
00079 
00080   if (vm.count("help"))
00081     set_action(ACTION_HELP);
00082 
00083   if (vm.count("version"))
00084     set_action(ACTION_VERSION);
00085 
00086   if (this->mountpoint.empty() &&
00087       this->action != ACTION_HELP &&
00088       this->action != ACTION_VERSION)
00089     throw opt::validation_error(_("No mount point specified"));
00090 }
00091 
00092 void
00093 options::set_action (action_type action)
00094 {
00095   if (this->action != ACTION_LISTMOUNTS)
00096     throw opt::validation_error(_("Only one action may be specified"));
00097 
00098   this->action = action;
00099 }

Generated on Sat Jan 27 16:11:04 2007 for schroot by  doxygen 1.5.1