]> Nishi Git Mirror - dataworks.git/commitdiff
the thing
authornishi <nishi@d4a5a174-5a4a-5b4b-b672-37683c10d7d5>
Wed, 22 May 2024 08:20:32 +0000 (08:20 +0000)
committernishi <nishi@d4a5a174-5a4a-5b4b-b672-37683c10d7d5>
Wed, 22 May 2024 08:20:32 +0000 (08:20 +0000)
git-svn-id: file:///raid/svn-main/nishi-dataworks/trunk@81 d4a5a174-5a4a-5b4b-b672-37683c10d7d5

Client/main.c

index c17e59380ab254960453c0c107a537fa45d7299e..c2514e2bce0a5886a0bd5f8cfbf1ddd500199cc2 100644 (file)
@@ -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;