thin-provisioning-tools/thin-provisioning/thin_delta.cc

51 lines
1016 B
C++
Raw Normal View History

2014-06-09 15:07:46 +05:30
#include <getopt.h>
#include <iostream>
2014-06-09 15:18:29 +05:30
#include <libgen.h>
2014-06-09 15:07:46 +05:30
#include "version.h"
using namespace std;
//----------------------------------------------------------------
2014-06-09 15:18:29 +05:30
namespace {
void usage(ostream &out, string const &cmd) {
out << "Usage: " << cmd << " [options]" << endl
<< "Options:" << endl
<< " {-h|--help}" << endl
<< " {-V|--version}" << endl;
}
}
//----------------------------------------------------------------
2014-06-09 15:07:46 +05:30
int main(int argc, char **argv)
{
int c;
2014-06-09 15:18:29 +05:30
char const shortopts[] = "hV";
2014-06-09 15:07:46 +05:30
option const longopts[] = {
2014-06-09 15:18:29 +05:30
{ "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, 'V' }
2014-06-09 15:07:46 +05:30
};
while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1) {
switch (c) {
2014-06-09 15:18:29 +05:30
case 'h':
usage(cout, basename(argv[0]));
return 0;
2014-06-09 15:07:46 +05:30
case 'V':
cout << THIN_PROVISIONING_TOOLS_VERSION << endl;
return 0;
default:
usage(cerr, basename(argv[0]));
return 1;
2014-06-09 15:07:46 +05:30
}
}
return 0;
}
//----------------------------------------------------------------