[shotwell] transformer: Check input parameters



commit 0b2e029eaee954b1ea9838920389ef99b643ea1f
Author: Jens Georg <mail jensge org>
Date:   Fri Mar 24 20:24:05 2017 +0100

    transformer: Check input parameters
    
    Signed-off-by: Jens Georg <mail jensge org>

 src/graphics-processor.vala |   24 ++++++++++++++++++------
 1 files changed, 18 insertions(+), 6 deletions(-)
---
diff --git a/src/graphics-processor.vala b/src/graphics-processor.vala
index 28968a7..c9e11d5 100644
--- a/src/graphics-processor.vala
+++ b/src/graphics-processor.vala
@@ -1,7 +1,7 @@
-static string input_file;
-static string output_file;
-static string pipeline;
-static bool auto_enhance;
+static string? input_file = null;
+static string? output_file = null;
+static string? pipeline = null;
+static bool auto_enhance = false;
 
 const GLib.OptionEntry[] options = {
     { "input", 'i', 0, GLib.OptionArg.FILENAME, ref input_file, "FILE to process", "FILE" },
@@ -37,8 +37,7 @@ Gee.HashMap<string, KeyValueMap>? marshall_all_transformations(string filename)
     }
 }
 
-int main(string[] args)
-{
+int main(string[] args) {
     var ctx = new OptionContext("- Apply shotwell transformations on commandline");
     ctx.set_help_enabled(true);
     ctx.set_ignore_unknown_options(true);
@@ -52,6 +51,19 @@ int main(string[] args)
         return 1;
     }
 
+    if (input_file == null || output_file == null) {
+        print("You need to provide and input and output file\n");
+        print(ctx.get_help(true, null));
+
+        return 1;
+    }
+
+    if (auto_enhance == false && pipeline == null) {
+        print("No operation provided. Nothing to do.\n");
+
+        return 0;
+    }
+
     Gdk.Pixbuf? src = null;
     try {
         src = new Gdk.Pixbuf.from_file(input_file);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]