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