Fixed switch to if statement
[appc.git] / appc-common / src / main / java / org / onap / appc / CmdLine.java
index d63bd87..383de89 100644 (file)
@@ -29,32 +29,27 @@ import org.onap.appc.encryption.EncryptionTool;
 public class CmdLine {
 
         public static void main(String[] args) {
-        if(args.length <= 1 || args.length >= 3){
-            printUsage();
-        }else{
-            String command = args[0];
-            
-            switch(command){
-                case "encrypt":
-                    if(args[1]!= null){
-                        String clearText = args[1];
-                        String encrypted = EncryptionTool.getInstance().encrypt(clearText);
-                        System.out.println(encrypted);                        
-                    }else{
-                        printUsage();
-                    }
-                    break;
-                default:
-                    printUsage();
-                    break;
-                
+
+            if (args.length < 1) {
+                printUsage();
+                return;
+            }
+
+            String command = args[0];//first parameter
+
+            if (0 == command.compareTo("encrypt") && args.length == 2)//two parameters are required
+            {
+                String clearText = args[1];
+                String encrypted = EncryptionTool.getInstance().encrypt(clearText);
+                System.out.println(encrypted);
+                return;
+            } else {
+                printUsage();
             }
-          }
-            
         }
         
         private static void printUsage(){
             System.out.println("Usage: java -jar <this jar> ...");
             System.out.println("\tencrypt <your text> \t\t(Encrypts your text)");
         }
-}
+}
\ No newline at end of file