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