From b7d977596d75cc2bb1127ef5aec5216a7e5f96a4 Mon Sep 17 00:00:00 2001 From: David Ostrovsky Date: Sat, 9 Nov 2013 05:23:26 +0100 Subject: [PATCH] Update SSH commands description Change-Id: I2c660074dd1151c186d5a10ec3bf877804559640 --- Documentation/dev-plugins.txt | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/Documentation/dev-plugins.txt b/Documentation/dev-plugins.txt index c70019986d..679f6a2a17 100644 --- a/Documentation/dev-plugins.txt +++ b/Documentation/dev-plugins.txt @@ -387,7 +387,9 @@ Command implementations must extend the base class SshCommand: [source,java] ---- import com.google.gerrit.sshd.SshCommand; +import com.google.gerrit.sshd.CommandMetaData; +@CommandMetaData(name="print", descr="Print hello command") class PrintHello extends SshCommand { protected abstract void run() { stdout.print("Hello\n"); @@ -421,7 +423,7 @@ import com.google.gerrit.sshd.PluginCommandModule; class MyCommands extends PluginCommandModule { protected void configureCommands() { - command("print").to(PrintHello.class); + command(PrintHello.class); } } ---- @@ -471,6 +473,30 @@ $ ssh -p 29418 review.example.com shell ls $ ssh -p 29418 review.example.com shell ps ---- +Single command plugins are also supported. In this scenario plugin binds +SSH command to its own name. `SshModule` must inherit from +`SingleCommandPluginModule` class: + +[source,java] +---- +public class SshModule extends SingleCommandPluginModule { + @Override + protected void configure(LinkedBindingBuilder b) { + b.to(ShellCommand.class); + } +} +---- + +If the plugin above is deployed under sh.jar file in `$site/plugins` +directory, generic commands can be called without specifing the +actual SSH command. Note in the example below, that the called commands +`ls` and `ps` was not explicitly bound: + +---- +$ ssh -p 29418 review.example.com sh ls +$ ssh -p 29418 review.example.com sh ps +---- + [[configuration]] Configuration -------------