tweaks to command line

This commit is contained in:
Joe Thornber
2012-03-13 14:06:10 +00:00
parent 4a1484330d
commit 0e47d99218
3 changed files with 34 additions and 31 deletions

View File

@@ -48,12 +48,12 @@ namespace {
return 0;
}
void usage(string const &cmd) {
cerr << "Usage: " << cmd << " [options] {device|file}" << endl
<< "Options:" << endl
<< " {-q|--quiet}" << endl
<< " {-h|--help}" << endl
<< " {-V|--version}" << endl;
void usage(ostream &out, string const &cmd) {
out << "Usage: " << cmd << " [options] {device|file}" << endl
<< "Options:" << endl
<< " {-q|--quiet}" << endl
<< " {-h|--help}" << endl
<< " {-V|--version}" << endl;
}
}
@@ -72,7 +72,7 @@ int main(int argc, char **argv)
while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1) {
switch(c) {
case 'h':
usage(basename(argv[0]));
usage(cout, basename(argv[0]));
return 0;
case 'q':
@@ -84,14 +84,14 @@ int main(int argc, char **argv)
return 0;
default:
usage(basename(argv[0]));
usage(cerr, basename(argv[0]));
return 1;
}
}
if (argc == optind) {
cerr << "No output file provided." << endl;
usage(basename(argv[0]));
cerr << "No input file provided." << endl;
usage(cerr, basename(argv[0]));
exit(1);
}