diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2013-01-04 16:42:25 +0100 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2013-01-04 16:42:25 +0100 |
commit | e58e2abe96d73354ff9f25ef62a2ed51418aa8fb (patch) | |
tree | 67dbe747174a6d41719f8b4b5bc0ca6b79e1e7b6 /src | |
parent | 50ae19e65af7728bf53e41a5b1cc7e3f9b8bf3db (diff) | |
download | sonar-scanner-cli-e58e2abe96d73354ff9f25ef62a2ed51418aa8fb.tar.gz sonar-scanner-cli-e58e2abe96d73354ff9f25ef62a2ed51418aa8fb.zip |
SONARPLUGINS-2571 Make the Sonar Runner support a new "--version" option
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/sonar/runner/Main.java | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/src/main/java/org/sonar/runner/Main.java b/src/main/java/org/sonar/runner/Main.java index 0acaf7f..482f827 100644 --- a/src/main/java/org/sonar/runner/Main.java +++ b/src/main/java/org/sonar/runner/Main.java @@ -48,6 +48,7 @@ public final class Main { private static final String PROJECT_SETTINGS = "project.settings"; private boolean debugMode = false; + private boolean displayVersionOnly = false; /** * Entry point of the program. @@ -81,6 +82,9 @@ public final class Main { } catch (IOException e) { throw new RunnerException(e); } + if (displayVersionOnly) { + return; + } runner.execute(); } finally { stats.stop(); @@ -168,12 +172,15 @@ public final class Main { String arg = args[i]; if ("-h".equals(arg) || "--help".equals(arg)) { printUsage(); - - } else if ("-X".equals(arg) || "--debug".equals(arg)) { + } + else if ("-v".equals(arg) || "--version".equals(arg)) { + displayVersionOnly = true; + } + else if ("-X".equals(arg) || "--debug".equals(arg)) { props.setProperty(Runner.PROPERTY_VERBOSE, "true"); debugMode = true; - - } else if ("-D".equals(arg) || "--define".equals(arg)) { + } + else if ("-D".equals(arg) || "--define".equals(arg)) { i++; if (i >= args.length) { printError("Missing argument for option --define"); @@ -181,11 +188,13 @@ public final class Main { arg = args[i]; appendPropertyTo(arg, props); - } else if (arg.startsWith("-D")) { + } + else if (arg.startsWith("-D")) { arg = arg.substring(2); appendPropertyTo(arg, props); - } else { + } + else { printError("Unrecognized option: " + arg); } } @@ -217,8 +226,9 @@ public final class Main { Logs.info(""); Logs.info("Options:"); Logs.info(" -h,--help Display help information"); + Logs.info(" -v,--version Display version information"); Logs.info(" -X,--debug Produce execution debug output"); Logs.info(" -D,--define <arg> Define property"); - System.exit(0); // NOSONAR + System.exit(0); } } |