Commit 274dcd17 authored by Seblu's avatar Seblu

get opt version added

parent bd4503dd
......@@ -37,8 +37,9 @@ Options::Options() {
*/
void Options::usage(const char *name, ostream &out) const {
out << "usage: " << name
<< " [-h|--help] [-l|--login name] [-v|--verbose] server [port]" << std::endl;
<< " [-h|--help] [-l|--login name] [-V|--version] server [port]" << std::endl;
out << "-h | --help : Print this help." << std::endl;
out << "-V | --version : Print version and exit." << std::endl;
out << "-l | --login name : Define login to name." << std::endl;
}
......@@ -53,16 +54,21 @@ void Options::usage(const char *name, ostream &out) const {
Options &Options::load(int argc, char *argv[]) {
struct option lopt[] = {
{"help", 0, 0, 'h'},
{"version", 0, 0, 'V'},
{"login", 0, 0, 'l'},
{0, 0, 0, 0},
};
int option;
while ((option = getopt_long(argc, argv, "hl:", lopt, 0)) != -1) {
while ((option = getopt_long(argc, argv, "Vhl:", lopt, 0)) != -1) {
switch (option) {
case 'h':
usage(*argv, std::cout);
break;
case 'V':
std::cout << "Version: " << VERSION << std::endl;
exit(ERR_NO);
break;
case 'l':
printf("login %s\n", optarg);
login = optarg;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment