Kaynağa Gözat

Restructured command line interafce

Yannick Ulrich 3 yıl önce
ebeveyn
işleme
313dfc2c05
1 değiştirilmiş dosya ile 19 ekleme ve 12 silme
  1. 19 12
      main.c

+ 19 - 12
main.c

@@ -160,23 +160,30 @@ main(int argc, char *argv[])
     struct Job job;
     make_socket_path();
 
-    if (argc != 4) {
-        printf("usage: %s burst-dir target-name save-dng\n", argv[0]);
-        exit(1);
-    }
+    if (argc == 4) {
+        // Parse command line arguments into the job struct
+        job.pid = 0;
+        strncpy(job.burstdir, argv[1], sizeof(job.burstdir));
+        strncpy(job.target, argv[2], sizeof(job.target));
+        if (strcmp(argv[3], "0") == 0) {
+            job.savedng = 0;
+        } else {
+            job.savedng = 1;
+        }
 
+        if(queue_job(job)) return 0;
 
-    // Parse command line arguments into the job struct
-    job.pid = 0;
-    strncpy(job.burstdir, argv[1], sizeof(job.burstdir));
-    strncpy(job.target, argv[2], sizeof(job.target));
-    if (strcmp(argv[3], "0") == 0) {
-        job.savedng = 0;
+        if(listen_and_convert(1))
+            queue_job(job);
+    } else if (argc == 2) {
+        if (strcmp(argv[1], "--daemon") == 0) {
+            listen_and_convert(0);
+        }
     } else {
-        job.savedng = 1;
+        printf("usage: %s burst-dir target-name save-dng\n", argv[0]);
+        exit(1);
     }
 
-    if(queue_job(job)) return 0;
 
     if(listen_and_convert(1))
         queue_job(job);