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 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-releaselock-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_releaselock;
00037 
00038 const options::action_type options::ACTION_RELEASELOCK ("releaselock");
00039 
00040 options::options ():
00041   schroot_base::options(),
00042   device(),
00043   pid(0),
00044   lock(_("Lock"))
00045 {
00046 }
00047 
00048 options::~options ()
00049 {
00050 }
00051 
00052 void
00053 options::add_options ()
00054 {
00055   // Chain up to add basic options.
00056   schroot_base::options::add_options();
00057 
00058   action.add(ACTION_RELEASELOCK);
00059   action.set_default(ACTION_RELEASELOCK);
00060 
00061   lock.add_options()
00062     ("device,d", opt::value<std::string>(&this->device),
00063      _("Device to unlock (full path)"))
00064     ("pid,p", opt::value<int>(&this->pid),
00065      _("Process ID owning the lock"));
00066 }
00067 
00068 void
00069 options::add_option_groups ()
00070 {
00071   // Chain up to add basic option groups.
00072   schroot_base::options::add_option_groups();
00073 
00074 #ifndef BOOST_PROGRAM_OPTIONS_DESCRIPTION_OLD
00075   if (!lock.options().empty())
00076 #else
00077   if (!lock.primary_keys().empty())
00078 #endif
00079     {
00080       visible.add(lock);
00081       global.add(lock);
00082     }
00083 }
00084 
00085 void
00086 options::check_options ()
00087 {
00088   // Chain up to check basic options.
00089   schroot_base::options::check_options();
00090 
00091   if (this->action == ACTION_RELEASELOCK &&
00092       this->device.empty())
00093     throw opt::validation_error(_("No device specified"));
00094 }

Generated on Sun Jul 8 21:23:55 2007 for schroot by  doxygen 1.5.2