diff --git a/source/arg_func.cpp b/source/arg_func.cpp index 5b158f6..b880919 100644 --- a/source/arg_func.cpp +++ b/source/arg_func.cpp @@ -41,42 +41,52 @@ Arg get_args(int argc, char **argv, char **label) return Arg::Error; } - if (!strcmp("-h", argv[1])) - { - print_args(); - return Arg::Error; - } - - if (!strcmp("-l", argv[1])) - return Arg::List; - if (!strcmp("-p", argv[1])) - return Arg::Print_all_p; - if (!strcmp("-c", argv[1])) - return Arg::Change; - - if (argc < 3) + if (argv[1][0] != '-') { *label = argv[1]; return Arg::Get; } + switch (argv[1][1]) + { + case 'h': + print_args(); + return Arg::Error; + case 'l': + return Arg::List; + case 'p': + return Arg::Print_all_p; + case 'c': + return Arg::Change; + } + + if (argc != 3) + return Arg::Error; + *label = argv[2]; - if (!strcmp("-g", argv[1])) + switch (argv[1][1]) + { + case 'g': return Arg::Generate; - if (!strcmp("-d", argv[1])) + case 'd': return Arg::Delete; - if (!strcmp("-i", argv[1])) + case 'i': return Arg::Input; - if (!strcmp("-s", argv[1])) + case 's': return Arg::Show; - if (!strcmp("-u", argv[1])) + case 'u': return Arg::Username; - if (!strcmp("-n", argv[1])) + case 'n': return Arg::Name; - if (!strcmp("-f", argv[1])) + case 'f': return Arg::File; + default: + return Arg::Error; + break; + } + return Arg::Error; }