[thin_restore] Tweak usage message.

This commit is contained in:
Joe Thornber 2013-06-27 09:44:46 +01:00
parent b7bdf1a3f2
commit 7cab21c8e7

View File

@ -58,8 +58,8 @@ namespace {
out << "Usage: " << cmd << " [options]" << endl out << "Usage: " << cmd << " [options]" << endl
<< "Options:" << endl << "Options:" << endl
<< " {-h|--help}" << endl << " {-h|--help}" << endl
<< " {-i|--input} input_file" << endl << " {-i|--input} <input xml file>" << endl
<< " {-o|--output} {device|file}" << endl << " {-o|--output} <output device or file>" << endl
<< " {-V|--version}" << endl; << " {-V|--version}" << endl;
} }
} }
@ -67,6 +67,7 @@ namespace {
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
int c; int c;
char const *prog_name = basename(argv[0]);
const char *shortopts = "hi:o:V"; const char *shortopts = "hi:o:V";
string input, output; string input, output;
const struct option longopts[] = { const struct option longopts[] = {
@ -80,7 +81,7 @@ int main(int argc, char **argv)
while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1) { while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1) {
switch(c) { switch(c) {
case 'h': case 'h':
usage(cout, basename(argv[0])); usage(cout, prog_name);
return 0; return 0;
case 'i': case 'i':
@ -96,25 +97,25 @@ int main(int argc, char **argv)
return 0; return 0;
default: default:
usage(cerr, basename(argv[0])); usage(cerr, prog_name);
return 1; return 1;
} }
} }
if (argc != optind) { if (argc != optind) {
usage(cerr, basename(argv[0])); usage(cerr, prog_name);
return 1; return 1;
} }
if (input.empty()) { if (input.empty()) {
cerr << "No input file provided." << endl; cerr << "No input file provided." << endl << endl;
usage(cerr, basename(argv[0])); usage(cerr, prog_name);
return 1; return 1;
} }
if (output.empty()) { if (output.empty()) {
cerr << "No output file provided." << endl; cerr << "No output file provided." << endl << endl;
usage(cerr, basename(argv[0])); usage(cerr, prog_name);
return 1; return 1;
} }