From: nishi Date: Wed, 22 May 2024 08:20:32 +0000 (+0000) Subject: the thing X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=09e77afe08943b3b2d81998526929141319f0c90;p=dataworks.git the thing git-svn-id: file:///raid/svn-main/nishi-dataworks/trunk@81 d4a5a174-5a4a-5b4b-b672-37683c10d7d5 --- diff --git a/Client/main.c b/Client/main.c index c17e593..c2514e2 100644 --- a/Client/main.c +++ b/Client/main.c @@ -54,8 +54,10 @@ void padleft(int leftpad, const char* str) { int main(int argc, char** argv) { int i; - bool noclear = false; + bool clear = true; bool create = false; + bool banner = true; + bool log = true; const char* fname = NULL; for(i = 1; i < argc; i++) { if(argv[i][0] == '-') { @@ -64,8 +66,15 @@ int main(int argc, char** argv) { return 0; } else if(strcmp(argv[i], "--create") == 0 || strcmp(argv[i], "-C") == 0) { create = true; - } else if(strcmp(argv[i], "--noclear") == 0) { - noclear = true; + } else if(strcmp(argv[i], "--noclear") == 0 || strcmp(argv[i], "-NC") == 0) { + clear = false; + } else if(strcmp(argv[i], "--quiet") == 0 || strcmp(argv[i], "-q") == 0) { + banner = false; + log = false; + } else if(strcmp(argv[i], "--nobanner") == 0 || strcmp(argv[i], "-NB") == 0) { + banner = false; + } else if(strcmp(argv[i], "--nolog") == 0 || strcmp(argv[i], "-NL") == 0) { + log = false; } else { fprintf(stderr, "%s: %s: invalid option\n", argv[0], argv[i]); return 1; @@ -90,46 +99,54 @@ int main(int argc, char** argv) { mode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING; SetConsoleMode(winstdout, mode); #endif - if(!noclear) { + if(clear) { printf("\x1b[2J\x1b[1;1H"); fflush(stdout); } - printf("DataWorks version %s %s %s\n", dataworks_get_version(), dataworks_get_compile_date(), dataworks_get_platform()); - if(dataworks_get_endian() == 'L') { - printf("This system is little-endian.\n"); - } else { - printf("This system is big-endian.\n"); + if(banner){ + printf("DataWorks version %s %s %s\n", dataworks_get_version(), dataworks_get_compile_date(), dataworks_get_platform()); + if(dataworks_get_endian() == 'L') { + printf("This system is little-endian.\n"); + } else { + printf("This system is big-endian.\n"); + } + printf("\n"); + printf("%s\n", dataworks_get_copyright()); + printf("All rights reserved.\n"); } - printf("\n"); - printf("%s\n", dataworks_get_copyright()); - printf("All rights reserved.\n"); if(create) { - printf("\n"); - printf("Creating the database: %s\n", fname); + if(log){ + printf("\n"); + printf("Creating the database: %s\n", fname); + } int n = dataworks_database_create(fname); if(n != 0) { printf("Failed to create.\n"); return 1; } else { - printf("Created successfully.\n"); + if(log) printf("Created successfully.\n"); } } - printf("\n"); - printf("Opening the database: %s\n", fname); + if(log){ + printf("\n"); + printf("Opening the database: %s\n", fname); + } struct dataworks_db* db = dataworks_database_open(fname); if(db->error) { printf("%s.\n", dataworks_database_strerror(db->errnum)); dataworks_database_close(db); return 1; } - time_t mtime = (time_t)dataworks_database_get_mtime(db); - struct tm* tm = localtime(&mtime); - char mtimestr[256]; - strftime(mtimestr, 255, "%a %b %d %H:%M:%S %Z %Y", tm); - printf("Opened the database (Version %d, Modified at %s).\n", dataworks_database_get_version(db), mtimestr); - printf("\n"); - printf("Type a command (.help) for the help.\n"); - printf("\n"); + if(log){ + time_t mtime = (time_t)dataworks_database_get_mtime(db); + struct tm* tm = localtime(&mtime); + char mtimestr[256]; + strftime(mtimestr, 255, "%a %b %d %H:%M:%S %Z %Y", tm); + printf("Opened the database (Version %d, Modified at %s).\n", dataworks_database_get_version(db), mtimestr); + printf("\n"); + printf("Type a command (.help) for the help.\n"); + printf("\n"); + } int len = 0; char* buf = malloc(1); buf[0] = 0;