From 76e07fe5e0b26578a4309e93c25ead58ac6cd8f5 Mon Sep 17 00:00:00 2001 From: Bob Polis Date: Sun, 21 Jul 2024 20:30:39 +0200 Subject: [PATCH] Small coding changes --- src/main.cpp | 41 ++++++++++++----------------------------- 1 file changed, 12 insertions(+), 29 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 81922d6..8626e71 100644 --- a/src/main.cpp +++ b/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) {