diff options
author | Oskar <[email protected]> | 2024-10-15 19:25:06 +0200 |
---|---|---|
committer | Oskar <[email protected]> | 2024-10-15 19:25:06 +0200 |
commit | 53f0b348c00e6c6fd2671acea984b842a87039c4 (patch) | |
tree | ad7edc1f177f134c5ec0bdf1c49bc350f386275f | |
parent | 4749fe202817a1bce220c778ddbf4f6d01fcc4e1 (diff) |
debug options text, fixed some option if statements
-rw-r--r-- | trashsystem2.cpp | 97 |
1 files changed, 77 insertions, 20 deletions
diff --git a/trashsystem2.cpp b/trashsystem2.cpp index 5df7cf4..b025a69 100644 --- a/trashsystem2.cpp +++ b/trashsystem2.cpp @@ -22,23 +22,23 @@ char *g_argv = nullptr; inline void usage_out(std::ostream &out) { - out << USAGE; + out << USAGE << std::ends; } inline void usage_out_long(std::ostream &out) { - out << LONG_USAGE; + out << LONG_USAGE << std::ends; } int main (int argc, char **argv) { - + g_argv = argv[0]; if (argc == 1) { usage_out(std::cerr); return EXIT_FAILURE; } - - int r_mtx = 0; + + int R_mtx = 0; int C_mtx = 0; int c_mtx = 0; int L_mtx = 0; @@ -47,57 +47,114 @@ int main (int argc, char **argv) { int n_mtx = 0; int f_mtx = 0; int h_mtx = 0; - bool y_used; - bool n_used; - bool v_used; - bool f_used; - bool t_used; - bool l_used; - bool L_used; - bool c_used; - bool C_used; - bool R_used; - bool h_used; + bool y_used = false; + bool n_used = false; + bool v_used = false; + bool f_used = false; + bool t_used = false; + bool l_used = false; + bool L_used = false; + bool c_used = false; + bool C_used = false; + bool R_used = false; + bool h_used = false; int opt = 0; while((opt = getopt(argc, argv, "ynvfatlLcCR:h")) != -1) { switch(opt) { case 'y': + y_mtx = 1; + y_used = true; + break; case 'n': - + + n_mtx = 1; + n_used = true; + break; case 'v': + v_used = true; + break; case 'f': + + f_mtx = 1; + f_used = true; break; case 't': + t_used = true; + break; case 'l': + l_mtx = 1; + l_used = true; + break; case 'L': + L_mtx = 1; + L_used = true; + break; case 'c': + + c_mtx = 1; + c_used = true; break; case 'C': - + + C_mtx = 1; + C_used = true; + break; case 'R': - + + R_mtx = 1; + R_used = true; + break; case 'h': + h_mtx = 1; + h_used = true; + break; } } - + + DEBUG_STREAM(<< "Used options [ynvftlLcCRh]: " + << y_used << n_used << v_used + << f_used << t_used << l_used + << L_used << c_used << C_used + << R_used << h_used << std::endl); + if((R_mtx + C_mtx + c_mtx + L_mtx + l_mtx + h_mtx) > 1) { + usage_out(std::cerr); + return EXIT_FAILURE; + } + + if((y_mtx + n_mtx + f_mtx + h_mtx) > 1) { + usage_out(std::cerr); + return EXIT_FAILURE; + } + + if(optind == argc && (l_used || L_used || C_used || c_used || h_used || R_used) == false) { + usage_out(std::cerr); + return EXIT_FAILURE; + } + + if(h_used == true) { + usage_out_long(std::cout); + return EXIT_SUCCESS; + } + + if(y_used || n_used || v_used || f_used || t_used) {} std::cout << "Smoketest" << std::endl; std::cout << argc << std::endl; std::cout << argv[0] << std::endl; |