Mercurial > hg > release > thermostat-2.0
changeset 2485:97a5c72996b4
Add thermostat configuration info to CLI.
This allows 'thermostat --info' to be run which shows the location of
USER_THERMOSTAT_HOME and THERMOSTAT_HOME.
Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2016-October/021354.html
Reviewed-by: aazores, jerboaa
author | Jie Kang <jkang@redhat.com> |
---|---|
date | Fri, 21 Oct 2016 10:03:50 -0400 |
parents | c6d0e7c16513 |
children | 9af295714d77 |
files | config/src/main/java/com/redhat/thermostat/shared/config/CommonPaths.java config/src/main/java/com/redhat/thermostat/shared/config/internal/CommonPathsImpl.java integration-tests/itest-run/src/test/java/com/redhat/thermostat/itest/CliTest.java launcher/src/main/java/com/redhat/thermostat/launcher/internal/LauncherImpl.java |
diffstat | 4 files changed, 31 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/config/src/main/java/com/redhat/thermostat/shared/config/CommonPaths.java Thu Oct 20 11:32:47 2016 -0400 +++ b/config/src/main/java/com/redhat/thermostat/shared/config/CommonPaths.java Fri Oct 21 10:03:50 2016 -0400 @@ -58,6 +58,8 @@ */ @Service public interface CommonPaths { + String THERMOSTAT_HOME = "THERMOSTAT_HOME"; + String USER_THERMOSTAT_HOME = "USER_THERMOSTAT_HOME"; public File getSystemThermostatHome() throws InvalidConfigurationException;
--- a/config/src/main/java/com/redhat/thermostat/shared/config/internal/CommonPathsImpl.java Thu Oct 20 11:32:47 2016 -0400 +++ b/config/src/main/java/com/redhat/thermostat/shared/config/internal/CommonPathsImpl.java Fri Oct 21 10:03:50 2016 -0400 @@ -83,8 +83,6 @@ // them whenever you change this class. // environment variables (also system properties for convenience): - private static final String THERMOSTAT_HOME = "THERMOSTAT_HOME"; - private static final String USER_THERMOSTAT_HOME = "USER_THERMOSTAT_HOME"; private static final String THERMOSTAT_SYSTEM_USER = "THERMOSTAT_SYSTEM_USER";
--- a/integration-tests/itest-run/src/test/java/com/redhat/thermostat/itest/CliTest.java Thu Oct 20 11:32:47 2016 -0400 +++ b/integration-tests/itest-run/src/test/java/com/redhat/thermostat/itest/CliTest.java Fri Oct 21 10:03:50 2016 -0400 @@ -140,6 +140,22 @@ } @Test + public void testInfoArgument() throws Exception { + Spawn shell = spawnThermostat("--info"); + shell.expectClose(); + + String stdOut = shell.getCurrentStandardOutContents(); + String stdErr = shell.getCurrentStandardErrContents(); + + String thHomeLineMatch = "THERMOSTAT_HOME=.*\n"; + String thUserHomeLineMatch = "USER_THERMOSTAT_HOME=.*\n"; + String matchString = thHomeLineMatch + thUserHomeLineMatch; + + assertTrue("Incorrect match " + stdOut + "\n\n", stdOut.matches(matchString)); + assertEquals(stdErr, ""); + } + + @Test public void testShell() throws Exception { Spawn shell = spawnThermostat("shell");
--- a/launcher/src/main/java/com/redhat/thermostat/launcher/internal/LauncherImpl.java Thu Oct 20 11:32:47 2016 -0400 +++ b/launcher/src/main/java/com/redhat/thermostat/launcher/internal/LauncherImpl.java Fri Oct 21 10:03:50 2016 -0400 @@ -95,6 +95,7 @@ private static final Set<String> HELP_SET; private static final String HELP_COMMAND_NAME = "help"; private static final String HELP_OPTION = "--help"; + private static final String INFO_OPTION = "--info"; private static final Translate<LocaleResources> t = LocaleResources.createLocalizer(); private static final Logger logger = LoggingUtils.getLogger(LauncherImpl.class); @@ -170,6 +171,10 @@ // We want to print the version of core // thermostat, so we use the no-arg constructor of Version cmdCtxFactory.getConsole().getOutput().println(coreVersion.getVersionInfo()); + } else if (isInfoQuery(args, inShell)) { + PrintStream stdOut = cmdCtxFactory.getConsole().getOutput(); + stdOut.println(CommonPaths.THERMOSTAT_HOME + "=" + paths.getSystemThermostatHome().getAbsolutePath()); + stdOut.println(CommonPaths.USER_THERMOSTAT_HOME + "=" + paths.getUserThermostatHome().getAbsolutePath()); } else { // With web-always-on we need to make sure that the setup ran. if (isSomeHelpInvocation(args) || isThermostatConfigured()) { @@ -491,5 +496,13 @@ } } + private boolean isInfoQuery(String[] args, boolean inShell) { + // don't allow --info in the shell + if (inShell) { + return false; + } else { + return args[0].equals(INFO_OPTION); + } + } }