Commit: 7416021bf720f6f8a16a044e11be69d17e1680de
Author: Campbell Barton
Date:   Wed Jan 25 12:20:48 2023 +1100
Branches: master
https://developer.blender.org/rB7416021bf720f6f8a16a044e11be69d17e1680de

Command Line Arguments: all errors now print to the stderr

This was done by some callbacks but not all.
Only use the stdout for status & information.

===================================================================

M       source/creator/creator_args.c

===================================================================

diff --git a/source/creator/creator_args.c b/source/creator/creator_args.c
index a53ee46b00a..7eb37982086 100644
--- a/source/creator/creator_args.c
+++ b/source/creator/creator_args.c
@@ -792,7 +792,7 @@ static int arg_handle_log_level_set(int argc, const char 
**argv, void *UNUSED(da
   if (argc > 1) {
     const char *err_msg = NULL;
     if (!parse_int_clamp(argv[1], NULL, -1, INT_MAX, &G.log.level, &err_msg)) {
-      printf("\nError: %s '%s %s'.\n", err_msg, arg_id, argv[1]);
+      fprintf(stderr, "\nError: %s '%s %s'.\n", err_msg, arg_id, argv[1]);
     }
     else {
       if (G.log.level == -1) {
@@ -802,7 +802,7 @@ static int arg_handle_log_level_set(int argc, const char 
**argv, void *UNUSED(da
     }
     return 1;
   }
-  printf("\nError: '%s' no args given.\n", arg_id);
+  fprintf(stderr, "\nError: '%s' no args given.\n", arg_id);
   return 0;
 }
 
@@ -852,7 +852,7 @@ static int arg_handle_log_file_set(int argc, const char 
**argv, void *UNUSED(dat
     FILE *fp = BLI_fopen(argv[1], "w");
     if (fp == NULL) {
       const char *err_msg = errno ? strerror(errno) : "unknown";
-      printf("\nError: %s '%s %s'.\n", err_msg, arg_id, argv[1]);
+      fprintf(stderr, "\nError: %s '%s %s'.\n", err_msg, arg_id, argv[1]);
     }
     else {
       if (UNLIKELY(G.log.file != NULL)) {
@@ -863,7 +863,7 @@ static int arg_handle_log_file_set(int argc, const char 
**argv, void *UNUSED(dat
     }
     return 1;
   }
-  printf("\nError: '%s' no args given.\n", arg_id);
+  fprintf(stderr, "\nError: '%s' no args given.\n", arg_id);
   return 0;
 }
 
@@ -906,7 +906,7 @@ static int arg_handle_log_set(int argc, const char **argv, 
void *UNUSED(data))
     }
     return 1;
   }
-  printf("\nError: '%s' no args given.\n", arg_id);
+  fprintf(stderr, "\nError: '%s' no args given.\n", arg_id);
   return 0;
 }
 
@@ -1091,7 +1091,7 @@ static int arg_handle_debug_value_set(int argc, const 
char **argv, void *UNUSED(
     const char *err_msg = NULL;
     int value;
     if (!parse_int(argv[1], NULL, &value, &err_msg)) {
-      printf("\nError: %s '%s %s'.\n", err_msg, arg_id, argv[1]);
+      fprintf(stderr, "\nError: %s '%s %s'.\n", err_msg, arg_id, argv[1]);
       return 1;
     }
 
@@ -1099,7 +1099,7 @@ static int arg_handle_debug_value_set(int argc, const 
char **argv, void *UNUSED(
 
     return 1;
   }
-  printf("\nError: you must specify debug value to set.\n");
+  fprintf(stderr, "\nError: you must specify debug value to set.\n");
   return 0;
 }
 
@@ -1188,7 +1188,7 @@ static int arg_handle_app_template(int argc, const char 
**argv, void *UNUSED(dat
     WM_init_state_app_template_set(app_template);
     return 1;
   }
-  printf("\nError: App template must follow '--app-template'.\n");
+  fprintf(stderr, "\nError: App template must follow '--app-template'.\n");
   return 0;
 }
 
@@ -1234,7 +1234,7 @@ static int arg_handle_env_system_set(int argc, const char 
**argv, void *UNUSED(d
   const char *ch_src = argv[0] + 5; /* skip --env */
 
   if (argc < 2) {
-    printf("%s requires one argument\n", argv[0]);
+    fprintf(stderr, "%s requires one argument\n", argv[0]);
     exit(1);
   }
 
@@ -1303,7 +1303,7 @@ static int arg_handle_window_geometry(int argc, const 
char **argv, void *UNUSED(
   for (i = 0; i < 4; i++) {
     const char *err_msg = NULL;
     if (!parse_int(argv[i + 1], NULL, &params[i], &err_msg)) {
-      printf("\nError: %s '%s %s'.\n", err_msg, arg_id, argv[1]);
+      fprintf(stderr, "\nError: %s '%s %s'.\n", err_msg, arg_id, argv[1]);
       exit(1);
     }
   }
@@ -1449,11 +1449,11 @@ static int arg_handle_output_set(int argc, const char 
**argv, void *data)
       DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
     }
     else {
-      printf("\nError: no blend loaded. cannot use '-o / --render-output'.\n");
+      fprintf(stderr, "\nError: no blend loaded. cannot use '-o / 
--render-output'.\n");
     }
     return 1;
   }
-  printf("\nError: you must specify a path after '-o  / --render-output'.\n");
+  fprintf(stderr, "\nError: you must specify a path after '-o  / 
--render-output'.\n");
   return 0;
 }
 
@@ -1481,20 +1481,20 @@ static int arg_handle_engine_set(int argc, const char 
**argv, void *data)
           DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
         }
         else {
-          printf("\nError: engine not found '%s'\n", argv[1]);
+          fprintf(stderr, "\nError: engine not found '%s'\n", argv[1]);
           exit(1);
         }
       }
       else {
-        printf(
-            "\nError: no blend loaded. "
-            "order the arguments so '-E / --engine' is after a blend is 
loaded.\n");
+        fprintf(stderr,
+                "\nError: no blend loaded. "
+                "order the arguments so '-E / --engine' is after a blend is 
loaded.\n");
       }
     }
 
     return 1;
   }
-  printf("\nEngine not specified, give 'help' for a list of available 
engines.\n");
+  fprintf(stderr, "\nEngine not specified, give 'help' for a list of available 
engines.\n");
   return 0;
 }
 
@@ -1516,9 +1516,9 @@ static int arg_handle_image_type_set(int argc, const char 
**argv, void *data)
       const char imtype_new = BKE_imtype_from_arg(imtype);
 
       if (imtype_new == R_IMF_IMTYPE_INVALID) {
-        printf(
-            "\nError: Format from '-F / --render-format' not known or not 
compiled in this "
-            "release.\n");
+        fprintf(stderr,
+                "\nError: Format from '-F / --render-format' not known or not 
compiled in this "
+                "release.\n");
       }
       else {
         scene->r.im_format.imtype = imtype_new;
@@ -1526,13 +1526,13 @@ static int arg_handle_image_type_set(int argc, const 
char **argv, void *data)
       }
     }
     else {
-      printf(
-          "\nError: no blend loaded. "
-          "order the arguments so '-F  / --render-format' is after the blend 
is loaded.\n");
+      fprintf(stderr,
+              "\nError: no blend loaded. "
+              "order the arguments so '-F  / --render-format' is after the 
blend is loaded.\n");
     }
     return 1;
   }
-  printf("\nError: you must specify a format after '-F  / 
--render-format'.\n");
+  fprintf(stderr, "\nError: you must specify a format after '-F  / 
--render-format'.\n");
   return 0;
 }
 
@@ -1548,19 +1548,24 @@ static int arg_handle_threads_set(int argc, const char 
**argv, void *UNUSED(data
     const char *err_msg = NULL;
     int threads;
     if (!parse_int_strict_range(argv[1], NULL, min, max, &threads, &err_msg)) {
-      printf("\nError: %s '%s %s', expected number in [%d..%d].\n",
-             err_msg,
-             arg_id,
-             argv[1],
-             min,
-             max);
+      fprintf(stderr,
+              "\nError: %s '%s %s', expected number in [%d..%d].\n",
+              err_msg,
+              arg_id,
+              argv[1],
+              min,
+              max);
       return 1;
     }
 
     BLI_system_num_threads_override_set(threads);
     return 1;
   }
-  printf("\nError: you must specify a number of threads in [%d..%d] '%s'.\n", 
min, max, arg_id);
+  fprintf(stderr,
+          "\nError: you must specify a number of threads in [%d..%d] '%s'.\n",
+          min,
+          max,
+          arg_id);
   return 0;
 }
 
@@ -1574,7 +1579,7 @@ static int arg_handle_verbosity_set(int argc, const char 
**argv, void *UNUSED(da
     const char *err_msg = NULL;
     int level;
     if (!parse_int(argv[1], NULL, &level, &err_msg)) {
-      printf("\nError: %s '%s %s'.\n", err_msg, arg_id, argv[1]);
+      fprintf(stderr, "\nError: %s '%s %s'.\n", err_msg, arg_id, argv[1]);
     }
 
 #  ifdef WITH_LIBMV
@@ -1587,7 +1592,7 @@ static int arg_handle_verbosity_set(int argc, const char 
**argv, void *UNUSED(da
 
     return 1;
   }
-  printf("\nError: you must specify a verbosity level.\n");
+  fprintf(stderr, "\nError: you must specify a verbosity level.\n");
   return 0;
 }
 
@@ -1609,17 +1614,18 @@ static int arg_handle_extension_set(int argc, const 
char **argv, void *data)
         DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
       }
       else {
-        printf("\nError: Use '-x 1 / -x 0' To set the extension option or 
'--use-extension'\n");
+        fprintf(stderr,
+                "\nError: Use '-x 1 / -x 0' To set the extension option or 
'--use-extension'\n");
       }
     }
     else {
-      printf(
-          "\nError: no blend loaded. "
-          "order the arguments so '-o ' is after '-x '.\n");
+      fprintf(stderr,
+              "\nError: no blend loaded. "
+              "order the arguments so '-o ' is after '-x '.\n");
     }
     return 1;
   }
-  printf("\nError: you must specify a path after '- '.\n");
+  fprintf(stderr, "\nError: you must specify a path after '- '.\n");
   return 0;
 }
 
@@ -1652,7 +1658,7 @@ static int arg_handle_render_frame(int argc, const char 
**argv, void *data)
                                                               MAXFRAME,
                                                               
&frames_range_len,
                                                               &err_msg)) == 
NULL) {
-        printf("\nError: %s '%s %s'.\n", err_msg, arg_id, argv[1]);
+        fprintf(stderr, "\nError: %s '%s %s'.\n", err_msg, arg_id, argv[1]);
         return 1;
       }
 
@@ -1663,7 +1669,7 @@ static int arg_handle_render_frame(int argc, const char 
**argv, void *data)
         /* We could pass in frame ranges,
          * but prefer having exact behavior as passing in multiple frames */
         if ((frame_range_arr[i][0] <= frame_range_arr[i][1]) == 0) {
-          printf("\nWarning: negative range ignored '%s %s'.\n", arg_id, 
argv[1]);
+          fprintf(stderr, "\nWarning: negative range ignored '%s %s'.\n", 
arg_id, argv[1]);
         }
 
         for (int frame = frame_range_arr[i][0]; frame <= 
frame_range_arr[i][1]; frame++) {
@@ -1675,10 +1681,10 @@ static int arg_handle_render_frame(int argc, const char 
**argv, void *data)
       MEM_freeN(frame_range_arr);
       return 1;
     }
-    printf("\nError: frame number must follow '%s'.\n", arg_id);
+    fprintf(stderr, "\nError: frame number must follow '%s'.\n", arg_id);
     return 0;
   }
-  printf("\nError: no blend loaded. cannot use '%s'.\n", arg_id);
+  fp

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to