Small coding changes
This commit is contained in:
parent
7689984870
commit
76e07fe5e0
41
src/main.cpp
41
src/main.cpp
@ -104,14 +104,14 @@ int main(int argc, char* argv[]) {
|
||||
try {
|
||||
int opt_char, opt_val;
|
||||
struct option long_options[] = {
|
||||
{"help", no_argument, nullptr, 'h'},
|
||||
{"version", no_argument, &opt_val, 1},
|
||||
{"add", required_argument, nullptr, 'a'},
|
||||
{"delete", required_argument, nullptr, 'd'},
|
||||
{"change", required_argument, nullptr, 'c'},
|
||||
{"delete", required_argument, nullptr, 'd'},
|
||||
{"help", no_argument, nullptr, 'h'},
|
||||
{"into", required_argument, nullptr, 'i'},
|
||||
{"list", no_argument, nullptr, 'l'},
|
||||
{"sort", no_argument, nullptr, 's'},
|
||||
{"version", no_argument, &opt_val, 1},
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
while ((opt_char = getopt_long(argc, argv, "a:c:d:hi:ls", long_options, nullptr)) != -1) {
|
||||
@ -120,35 +120,18 @@ int main(int argc, char* argv[]) {
|
||||
case 0: {
|
||||
// handle long-only options here
|
||||
switch (opt_val) {
|
||||
case 1:
|
||||
print_version();
|
||||
return EXIT_SUCCESS;
|
||||
case 1: print_version(); return EXIT_SUCCESS;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'a':
|
||||
additions.push_back(arg);
|
||||
break;
|
||||
case 'c':
|
||||
change = arg;
|
||||
break;
|
||||
case 'd':
|
||||
deletions.push_back(arg);
|
||||
break;
|
||||
case 'h':
|
||||
print_help();
|
||||
return EXIT_SUCCESS;
|
||||
case 'i':
|
||||
changes.emplace(change, arg);
|
||||
break;
|
||||
case 'l':
|
||||
should_list = true;
|
||||
break;
|
||||
case 's':
|
||||
sort = true;
|
||||
break;
|
||||
case '?':
|
||||
throw std::runtime_error("unrecognized option");
|
||||
case 'a': additions.push_back(arg); break;
|
||||
case 'c': change = arg; break;
|
||||
case 'd': deletions.push_back(arg); break;
|
||||
case 'h': print_help(); return EXIT_SUCCESS;
|
||||
case 'i': changes.emplace(change, arg); break;
|
||||
case 'l': should_list = true; break;
|
||||
case 's': sort = true; break;
|
||||
case '?': throw std::runtime_error("unrecognized option");
|
||||
}
|
||||
}
|
||||
if (optind == argc) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user