Make it VERY clear when nomulus shell is on PROD

We don't want people to accidentally run commands on prod thinking they were on
Alpha / Sandbox.

To do that - we add 2 safeguards:

1) when on prod, the shell has a strong RED "PRODUCTION" in the commandline, while on alpha/sandbox it's green.

2) if a prod shell is idle for > 1h, it exits. So don't accidentally use a prod shell from a long time ago.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=191931731
This commit is contained in:
guyben 2018-04-06 13:28:16 -07:00 committed by Ben McIlwain
parent 7bf0b059a6
commit 013558c814
3 changed files with 108 additions and 18 deletions

View file

@ -104,10 +104,9 @@ final class RegistryCli implements AutoCloseable, CommandRunner {
// Create the "help" and "shell" commands (these are special in that they don't have a default
// constructor).
jcommander.addCommand("help", new HelpCommand(jcommander));
ShellCommand shellCommand = null;
if (isFirstUse) {
isFirstUse = false;
shellCommand = new ShellCommand(this);
ShellCommand shellCommand = new ShellCommand(this);
// We have to build the completions based on the jcommander *before* we add the "shell"
// command - to avoid completion for the "shell" command itself.
shellCommand.buildCompletions(jcommander);
@ -139,11 +138,6 @@ final class RegistryCli implements AutoCloseable, CommandRunner {
checkState(RegistryToolEnvironment.get() == environment,
"RegistryToolEnvironment argument pre-processing kludge failed.");
// We have to set the prompt here, because the environment wasn't set until this point
if (shellCommand != null) {
shellCommand.setPrompt(String.format("nom@%s > ", environment));
}
// JCommander stores sub-commands as nested JCommander objects containing a list of user objects
// to be populated. Extract the subcommand by getting the JCommander wrapper and then
// retrieving the first (and, by virtue of our usage, only) object from it.