cleaned up code for arguments a bit

dev
Paul Cruz 2017-07-07 10:58:43 -07:00
parent f7e6b358d0
commit 532f439961
2 changed files with 31 additions and 32 deletions

View File

@ -515,39 +515,35 @@ int main(int argCount, const char* argv[])
const char* argument = argv[argNum];
/* output filename designated with "-o" */
if (argument[0]=='-') {
if (strlen(argument) > 1 && argument[1] == 'o') {
argument += 2;
outFilename = argument;
continue;
}
else if (strlen(argument) > 1 && argument[1] == 'v') {
g_displayLevel++;
continue;
}
else if (strlen(argument) > 1 && argument[1] == 'i') {
argument += 2;
g_compressionLevel = readU32FromChar(&argument);
DEBUGLOG(2, "g_compressionLevel: %u\n", g_compressionLevel);
continue;
}
else if (strlen(argument) > 1 && argument[1] == 's') {
g_displayStats = 1;
continue;
}
else if (strlen(argument) > 1 && argument[1] == 'h') {
help();
return 0;
}
else if (strlen(argument) > 1 && argument[1] == 'p') {
g_useProgressBar = 1;
continue;
}
else {
DISPLAY("Error: invalid argument provided\n");
ret = 1;
goto _main_exit;
if (argument[0]=='-' && strlen(argument) > 1) {
switch (argument[1]) {
case 'o':
argument += 2;
outFilename = argument;
break;
case 'v':
g_displayLevel++;
break;
case 'i':
argument += 2;
g_compressionLevel = readU32FromChar(&argument);
DEBUGLOG(2, "g_compressionLevel: %u\n", g_compressionLevel);
break;
case 's':
g_displayStats = 1;
break;
case 'h':
help();
goto _main_exit;
case 'p':
g_useProgressBar = 1;
break;
default:
DISPLAY("Error: invalid argument provided\n");
ret = 1;
goto _main_exit;
}
continue;
}
/* regular files to be compressed */

View File

@ -140,6 +140,9 @@ diff tests/test512.pdf tests/tmp512
diff tests/test1024.pdf tests/tmp1024
diff tests/test2048.pdf tests/tmp2048
echo "Running Args Tests"
./multi -h
./multi -i22 -p -s -otmp.zst tests/test2048.pdf
echo "finished with tests"
make clean