00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include <config.h>
00020
00021 #include "dchroot-options.h"
00022
00023 #include <cstdlib>
00024 #include <iostream>
00025
00026 #include <boost/format.hpp>
00027 #include <boost/program_options.hpp>
00028
00029 using std::endl;
00030 using sbuild::_;
00031 using boost::format;
00032 namespace opt = boost::program_options;
00033 using namespace dchroot;
00034
00035 options::options ():
00036 schroot::options_base()
00037 {
00038 }
00039
00040 options::~options ()
00041 {
00042 }
00043
00044 void
00045 options::add_options ()
00046 {
00047
00048 schroot::options_base::add_options();
00049
00050 actions.add_options()
00051 ("path,p", opt::value<std::string>(&this->chroot_path),
00052 _("Print path to selected chroot"));
00053
00054 chroot.add_options()
00055 ("all,a",
00056 _("Select all chroots"));
00057
00058 chrootenv.add_options()
00059 ("directory", opt::value<std::string>(&this->directory),
00060 _("Directory to use"))
00061 ("preserve-environment,d",
00062 _("Preserve user environment"));
00063 }
00064
00065 void
00066 options::check_options ()
00067 {
00068
00069 schroot::options_base::check_options();
00070
00071 if (vm.count("path"))
00072 this->action = ACTION_LOCATION;
00073
00074 if (vm.count("all"))
00075 {
00076 this->all = false;
00077 this->all_chroots = true;
00078 this->all_sessions = false;
00079 }
00080
00081 if (vm.count("preserve-environment"))
00082 this->preserve = true;
00083
00084 if (this->quiet && this->verbose)
00085 {
00086 sbuild::log_warning()
00087 << _("--quiet and --verbose may not be used at the same time")
00088 << endl;
00089 sbuild::log_info() << _("Using verbose output") << endl;
00090 }
00091
00092 if (!this->chroots.empty() && all_used())
00093 {
00094 sbuild::log_warning()
00095 << _("--chroot and --all may not be used at the same time")
00096 << endl;
00097 sbuild::log_info() << _("Using --chroots only") << endl;
00098 this->all = this->all_chroots = this->all_sessions = false;
00099 }
00100
00101 if (this->all == true)
00102 {
00103 this->all_chroots = true;
00104 this->all_sessions = true;
00105 }
00106 }