From 61cff8e33191f065bc9f5c35ec126e3662b9eb5f Mon Sep 17 00:00:00 2001 From: Sachin Goel Date: Sat, 28 Nov 2015 14:56:16 +0530 Subject: [PATCH] [FLINK-3077][cli] Add version option(-v, --version) to Cli. This closes #1418 --- .../main/java/org/apache/flink/client/CliFrontend.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/flink-clients/src/main/java/org/apache/flink/client/CliFrontend.java b/flink-clients/src/main/java/org/apache/flink/client/CliFrontend.java index 5a57bf4a077a0..6d902b51c4333 100644 --- a/flink-clients/src/main/java/org/apache/flink/client/CliFrontend.java +++ b/flink-clients/src/main/java/org/apache/flink/client/CliFrontend.java @@ -1000,11 +1000,20 @@ else if (action.equals("-h") || action.equals("--help")) { CliFrontendParser.printHelp(); return 0; } + else if (action.equals("-v") || action.equals("--version")) { + String version = EnvironmentInformation.getVersion(); + String commitID = EnvironmentInformation.getRevisionInformation().commitId; + System.out.print("Version: " + version); + System.out.println(!commitID.equals(EnvironmentInformation.UNKNOWN) ? ", Commit ID: " + commitID : ""); + return 0; + } else { System.out.printf("\"%s\" is not a valid action.\n", action); System.out.println(); System.out.println("Valid actions are \"run\", \"list\", \"info\", or \"cancel\"."); System.out.println(); + System.out.println("Specify the version option (-v or --version) to print Flink version."); + System.out.println(); System.out.println("Specify the help option (-h or --help) to get help on the command."); return 1; }