From cb67fc49edbea1fc6dad5e4ad5dab863586e9f23 Mon Sep 17 00:00:00 2001 From: Kuoi Date: Tue, 28 Feb 2023 16:02:03 +0800 Subject: [PATCH] polish arg --- tnt2winclada.cpp | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/tnt2winclada.cpp b/tnt2winclada.cpp index 9ff2648..1e1482b 100644 --- a/tnt2winclada.cpp +++ b/tnt2winclada.cpp @@ -18,41 +18,35 @@ void show_help (int help_num){ if (help_num == 0) { cout << "~|~|\\ |~|~ ~) | |o._ |~| _ _| _ " << endl; cout << " | | \\| | /_ \\/\\/ || ||_|(_|(_|(_|" << endl; - cout << "TNT2WinClada MIT\nplease use -h to see more help" << endl; + cout << "TNT2WinClada\nMIT, Guoyi Zhang, 2023\nplease use -h to see more options" << endl; } else { cout << "~|~|\\ |~|~ ~) | |o._ |~| _ _| _ " << endl; cout << " | | \\| | /_ \\/\\/ || ||_|(_|(_|(_|" << endl; - cout << "-h help;\n-i input: -i ${input_file};\n-o output: -o ${output_file}" << endl; + cout << "Usage: tnt2winclada -i ${input_file} -o ${output_file}\n-h help;\n-i input: -i ${input_file};\n-o output: -o ${output_file}" << endl; } } void argument(int argc, char **argv) { // -i -h -o option - int x=0, y = 0, z=0; for (int i = 0; i < argc; i++) { if (argc == 2 && string(argv[1]) == "-h") { show_help(1); - x++; - return; + exit(0); } if (argc != 5 || string(argv[1]) != "-i" || string(argv[3]) != "-o") { + cout << "input or output can't be empty." << endl; show_help(0); - return; + exit(0); } if (string(argv[i]) == "-i") { i++; inputFileName = argv[i]; - y++; } if (string(argv[i]) == "-o") { i++; outputFileName = argv[i]; - z++; } } - if (x==0 && (y==0 || z==0)) { - cout << "input or output can't be empty." << endl; - } } int read_tnt() {