schroot-releaselock-options.cc

Go to the documentation of this file.
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 3 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, see
00015  * <http://www.gnu.org/licenses/>.
00016  *
00017  *********************************************************************/
00018 
00019 #include <config.h>
00020 
00021 #include <sbuild/sbuild-i18n.h>
00022 
00023 #include "schroot-releaselock-options.h"
00024 
00025 #include <cstdlib>
00026 #include <iostream>
00027 
00028 #include <boost/format.hpp>
00029 #include <boost/program_options.hpp>
00030 
00031 using std::endl;
00032 using boost::format;
00033 using sbuild::_;
00034 namespace opt = boost::program_options;
00035 using namespace schroot_releaselock;
00036 
00037 const options::action_type options::ACTION_RELEASELOCK ("releaselock");
00038 
00039 options::options ():
00040   schroot_base::options(),
00041   device(),
00042   pid(0),
00043   lock(_("Lock"))
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_RELEASELOCK);
00058   action.set_default(ACTION_RELEASELOCK);
00059 
00060   lock.add_options()
00061     ("device,d", opt::value<std::string>(&this->device),
00062      _("Device to unlock (full path)"))
00063     ("pid,p", opt::value<int>(&this->pid),
00064      _("Process ID owning the lock"));
00065 }
00066 
00067 void
00068 options::add_option_groups ()
00069 {
00070   // Chain up to add basic option groups.
00071   schroot_base::options::add_option_groups();
00072 
00073 #ifndef BOOST_PROGRAM_OPTIONS_DESCRIPTION_OLD
00074   if (!lock.options().empty())
00075 #else
00076   if (!lock.primary_keys().empty())
00077 #endif
00078     {
00079       visible.add(lock);
00080       global.add(lock);
00081     }
00082 }
00083 
00084 void
00085 options::check_options ()
00086 {
00087   // Chain up to check basic options.
00088   schroot_base::options::check_options();
00089 
00090   if (this->action == ACTION_RELEASELOCK &&
00091       this->device.empty())
00092     throw opt::validation_error(_("No device specified"));
00093 }

Generated on Mon Jan 21 00:38:28 2008 for schroot by  doxygen 1.5.4