diff options
author | burdziak <olaf.burdziakowski@nokia.com> | 2018-01-19 10:12:09 +0100 |
---|---|---|
committer | Patrick Brady <pb071s@att.com> | 2018-01-19 18:39:00 +0000 |
commit | 442e579d63a7d2034a1595a97503046ea2181c29 (patch) | |
tree | ebff1c75748fe0e64b8be33c57dfc76aee4770cd /appc-common/src | |
parent | 831db8d4d93b955b0553f77b0bec1566a783d2b3 (diff) |
Fixed switch to if statement
Brakets added, initial check is requred before read of first argument.
Issue-ID: APPC-432
Change-Id: Id29d098d1e7358ebc3f53c19cfc60288793253d3
Signed-off-by: burdziak <olaf.burdziakowski@nokia.com>
Diffstat (limited to 'appc-common/src')
-rw-r--r-- | appc-common/src/main/java/org/onap/appc/CmdLine.java | 39 |
1 files changed, 17 insertions, 22 deletions
diff --git a/appc-common/src/main/java/org/onap/appc/CmdLine.java b/appc-common/src/main/java/org/onap/appc/CmdLine.java index d63bd8758..383de8949 100644 --- a/appc-common/src/main/java/org/onap/appc/CmdLine.java +++ b/appc-common/src/main/java/org/onap/appc/CmdLine.java @@ -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 |