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 "schroot-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 boost::format;
00031 using sbuild::_;
00032 namespace opt = boost::program_options;
00033 using namespace schroot;
00034
00035 options::options ():
00036 options_base()
00037 {
00038 }
00039
00040 options::~options ()
00041 {
00042 }
00043
00044 void
00045 options::add_options ()
00046 {
00047
00048 options_base::add_options();
00049
00050 actions.add_options()
00051 ("location",
00052 _("Print location of selected chroots"));
00053
00054 chroot.add_options()
00055 ("all,a",
00056 _("Select all chroots and active sessions"))
00057 ("all-chroots",
00058 _("Select all chroots"))
00059 ("all-sessions",
00060 _("Select all active sessions"));
00061
00062 chrootenv.add_options()
00063 ("directory,d", opt::value<std::string>(&this->directory),
00064 _("Directory to use"))
00065 ("user,u", opt::value<std::string>(&this->user),
00066 _("Username (default current user)"))
00067 ("preserve-environment,p",
00068 _("Preserve user environment"));
00069
00070 session_actions.add_options()
00071 ("automatic-session",
00072 _("Begin, run and end a session automatically (default)"))
00073 ("begin-session,b",
00074 _("Begin a session; returns a session ID"))
00075 ("recover-session",
00076 _("Recover an existing session"))
00077 ("run-session,r",
00078 _("Run an existing session"))
00079 ("end-session,e",
00080 _("End an existing session"));
00081
00082 session_options.add_options()
00083 ("session-name,n", opt::value<std::string>(&this->session_name),
00084 _("Session name (defaults to an automatically generated name)"))
00085 ("force,f",
00086 _("Force operation, even if it fails"));
00087 }
00088
00089
00090 void
00091 options::check_options ()
00092 {
00093
00094 options_base::check_options();
00095
00096 if (vm.count("location"))
00097 this->action = ACTION_LOCATION;
00098
00099 if (vm.count("all"))
00100 this->all = true;
00101 if (vm.count("all-chroots"))
00102 this->all_chroots = true;
00103 if (vm.count("all-sessions"))
00104 this->all_sessions = true;
00105
00106 if (vm.count("preserve-environment"))
00107 this->preserve = true;
00108
00109 if (vm.count("automatic-session"))
00110 this->action = ACTION_SESSION_AUTO;
00111 if (vm.count("begin-session"))
00112 this->action = ACTION_SESSION_BEGIN;
00113 if (vm.count("recover-session"))
00114 this->action = ACTION_SESSION_RECOVER;
00115 if (vm.count("run-session"))
00116 this->action = ACTION_SESSION_RUN;
00117 if (vm.count("end-session"))
00118 this->action = ACTION_SESSION_END;
00119 if (vm.count("force"))
00120 this->session_force = true;
00121
00122 if (this->all == true)
00123 {
00124 this->all_chroots = true;
00125 this->all_sessions = true;
00126 }
00127 }