Add description for commands disabled in slave mode

Running the `gerrit` ssh command without arguments to a server that
is running in slave mode results in a list of available commands
being shown.

In this list, the commands that are disabled in slave mode do not
have any description.

Add a description mentioning that the command is disabled due to
the server running in slave mode.

Bug: Issue 2424
Change-Id: Iffc43a921e70a9ed9008a62dcec12b80683b71b3
This commit is contained in:
David Pursehouse
2014-01-24 13:50:36 +09:00
parent 6ef51f6615
commit 84bcead690
2 changed files with 8 additions and 3 deletions

View File

@@ -21,6 +21,7 @@ import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.account.CapabilityUtils;
import com.google.gerrit.server.args4j.SubcommandHandler;
import com.google.gerrit.sshd.commands.ErrorSlaveMode;
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.assistedinject.Assisted;
@@ -154,9 +155,13 @@ final class DispatchCommand extends BaseCommand {
String format = "%-" + maxLength + "s %s";
for (String name : Sets.newTreeSet(commands.keySet())) {
final CommandProvider p = commands.get(name);
Command c = p.getProvider().get();
String description = c instanceof ErrorSlaveMode
? "Command disabled: server is running in slave mode"
: Strings.nullToEmpty(p.getDescription());
usage.append(" ");
usage.append(String.format(format, name,
Strings.nullToEmpty(p.getDescription())));
usage.append(String.format(format, name, description));
usage.append("\n");
}
usage.append("\n");