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 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 schroot::options_base::add_options();
00048
00049 general.add_options()
00050 ("path,p", opt::value<std::string>(&this->chroot_path),
00051 _("Print path to selected chroot"));
00052
00053 chroot.add_options()
00054 ("all,a",
00055 _("Select all chroots"));
00056
00057 chrootenv.add_options()
00058 ("directory", opt::value<std::string>(&this->directory),
00059 _("Directory to use"))
00060 ("preserve-environment,d",
00061 _("Preserve user environment"));
00062 }
00063
00064 void
00065 options::check_options ()
00066 {
00067 schroot::options_base::check_options();
00068
00069 if (vm.count("path"))
00070 set_action(ACTION_LOCATION);
00071
00072 if (vm.count("all"))
00073 {
00074 this->all = false;
00075 this->all_chroots = true;
00076 this->all_sessions = false;
00077 }
00078
00079 if (vm.count("preserve-environment"))
00080 this->preserve = true;
00081
00082 if (this->quiet && this->verbose)
00083 {
00084 sbuild::log_warning()
00085 << _("--quiet and --verbose may not be used at the same time")
00086 << endl;
00087 sbuild::log_info() << _("Using verbose output") << endl;
00088 }
00089
00090 if (!this->chroots.empty() && all_used())
00091 {
00092 sbuild::log_warning()
00093 << _("--chroot and --all may not be used at the same time")
00094 << endl;
00095 sbuild::log_info() << _("Using --chroots only") << endl;
00096 this->all = this->all_chroots = this->all_sessions = false;
00097 }
00098
00099 if (this->all == true)
00100 {
00101 this->all_chroots = true;
00102 this->all_sessions = true;
00103 }
00104 }