Remove po:: namespace and fix short options in thin_dump.cc. Switch thin_restore away from boost_rogram_options to getopt_long.
This commit is contained in:
parent
bad6aff58b
commit
6ba6d6a28c
@ -24,14 +24,10 @@
|
|||||||
#include "metadata.h"
|
#include "metadata.h"
|
||||||
#include "xml_format.h"
|
#include "xml_format.h"
|
||||||
|
|
||||||
#include <boost/program_options.hpp>
|
|
||||||
|
|
||||||
using namespace persistent_data;
|
using namespace persistent_data;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace thin_provisioning;
|
using namespace thin_provisioning;
|
||||||
|
|
||||||
namespace po = boost::program_options;
|
|
||||||
|
|
||||||
//----------------------------------------------------------------
|
//----------------------------------------------------------------
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@ -54,7 +50,7 @@ namespace {
|
|||||||
void usage(void) {
|
void usage(void) {
|
||||||
cerr << "Usage: thin_dump [options] <metadata device or file>" << endl << endl;
|
cerr << "Usage: thin_dump [options] <metadata device or file>" << endl << endl;
|
||||||
cerr << "Options:" << endl;
|
cerr << "Options:" << endl;
|
||||||
cerr << " --help Produce help message" << endl;
|
cerr << " -h [ --help ] Produce help message" << endl;
|
||||||
cerr << " -f [ --format ] arg (=xml) Select format (human_readable|xml)" << endl;
|
cerr << " -f [ --format ] arg (=xml) Select format (human_readable|xml)" << endl;
|
||||||
cerr << " -i [ --input ] arg Input file" << endl;
|
cerr << " -i [ --input ] arg Input file" << endl;
|
||||||
}
|
}
|
||||||
@ -63,7 +59,7 @@ namespace {
|
|||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
const char shortopts[] = "hfi";
|
const char shortopts[] = "hf:i:";
|
||||||
string filename, format = "xml";
|
string filename, format = "xml";
|
||||||
const struct option longopts[] = {
|
const struct option longopts[] = {
|
||||||
{ "help", no_argument, NULL, 'h'},
|
{ "help", no_argument, NULL, 'h'},
|
||||||
|
@ -24,14 +24,12 @@
|
|||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <boost/program_options.hpp>
|
#include <getopt.h>
|
||||||
|
|
||||||
using namespace persistent_data;
|
using namespace persistent_data;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace thin_provisioning;
|
using namespace thin_provisioning;
|
||||||
|
|
||||||
namespace po = boost::program_options;
|
|
||||||
|
|
||||||
//----------------------------------------------------------------
|
//----------------------------------------------------------------
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@ -53,45 +51,57 @@ namespace {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void usage(po::options_description const &desc) {
|
void usage(void) {
|
||||||
cerr << "Usage: thin_restore [options]" << endl << endl;
|
cerr << "Usage: thin_restore [options]" << endl << endl;
|
||||||
cerr << desc;
|
cerr << "Options:" << endl;
|
||||||
|
cerr << " -h [ --help ] Produce help message" << endl;
|
||||||
|
cerr << " -i [ --input ] arg Input file" << endl;
|
||||||
|
cerr << " -o [ --output ] arg Output file" << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
po::options_description desc("Options");
|
int c;
|
||||||
desc.add_options()
|
const char *shortopts = "hi:o:";
|
||||||
("help", "Produce help message")
|
string input, output;
|
||||||
("input,i", po::value<string>(), "Input file")
|
const struct option longopts[] = {
|
||||||
("output,o", po::value<string>(), "Output file")
|
{ "help", no_argument, NULL, 'h'},
|
||||||
;
|
{ "input", required_argument, NULL, 'i' },
|
||||||
|
{ "output", required_argument, NULL, 'o'},
|
||||||
|
{ NULL, no_argument, NULL, 0 }
|
||||||
|
};
|
||||||
|
|
||||||
po::variables_map vm;
|
while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1) {
|
||||||
po::store(po::command_line_parser(argc, argv).options(desc).run(), vm);
|
switch(c) {
|
||||||
po::notify(vm);
|
case 'h':
|
||||||
|
usage();
|
||||||
if (vm.count("help")) {
|
return 1;
|
||||||
usage(desc);
|
case 'i':
|
||||||
return 0;
|
input = optarg;
|
||||||
|
break;
|
||||||
|
case 'o':
|
||||||
|
output = optarg;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vm.count("input") != 1) {
|
if (argc == 1) {
|
||||||
cerr << "No input file provided." << endl;
|
usage();
|
||||||
usage(desc);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vm.count("output") != 1) {
|
if (input.empty()) {
|
||||||
cerr << "No output file provided." << endl;
|
cerr << "No input file name" << endl;
|
||||||
usage(desc);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
restore(vm["input"].as<string>(),
|
if (output.empty()) {
|
||||||
vm["output"].as<string>());
|
cerr << "No output file name" << endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
restore(input, output);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user