SSH: Inherit some commands from SshCommand

Some SSH command classes were unnecessary inherited from BaseCommand
and were doing stdout/stderr initialization on their own. That's what
SshCommand class is for.

Change-Id: Ia31f1dedbc46b0e19019c905d6b3fad1d87ba7a0
This commit is contained in:
David Ostrovsky
2014-08-06 09:10:31 +02:00
parent 7c51481994
commit 54525966c3
7 changed files with 59 additions and 124 deletions

View File

@@ -26,11 +26,10 @@ import com.google.gerrit.server.account.GroupCache;
import com.google.gerrit.server.account.GroupDetailFactory.Factory;
import com.google.gerrit.server.group.ListMembers;
import com.google.gerrit.server.ioutil.ColumnFormatter;
import com.google.gerrit.sshd.BaseCommand;
import com.google.gerrit.sshd.CommandMetaData;
import com.google.gerrit.sshd.SshCommand;
import com.google.gwtorm.server.OrmException;
import org.apache.sshd.server.Environment;
import org.kohsuke.args4j.Argument;
import java.io.PrintWriter;
@@ -43,24 +42,18 @@ import javax.inject.Inject;
*/
@CommandMetaData(name = "ls-members", description = "List the members of a given group",
runsAt = MASTER_OR_SLAVE)
public class ListMembersCommand extends BaseCommand {
public class ListMembersCommand extends SshCommand {
@Inject
ListMembersCommandImpl impl;
@Override
public void start(Environment env) {
startThread(new CommandRunnable() {
@Override
public void run() throws Exception {
parseCommandLine(impl);
final PrintWriter stdout = toPrintWriter(out);
try {
impl.display(stdout);
} finally {
stdout.flush();
}
}
});
public void run() throws Exception {
impl.display(stdout);
}
@Override
protected void parseCommandLine() throws UnloggedFailure {
parseCommandLine(impl);
}
private static class ListMembersCommandImpl extends ListMembers {