提交 3356de58 编写于 作者: K kohsuke

added the -s option

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@17602 71c3de6d-444a-0410-be80-ed276b4c234a
上级 8008042b
......@@ -30,6 +30,22 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jvnet.localizer</groupId>
<artifactId>maven-localizer-plugin</artifactId>
<version>1.9</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<fileMask>Messages.properties</fileMask>
<outputDirectory>target/generated-sources/localizer</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
......@@ -46,9 +62,9 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
<groupId>org.jvnet.localizer</groupId>
<artifactId>localizer</artifactId>
<version>1.9</version>
</dependency>
</dependencies>
</project>
......@@ -43,10 +43,27 @@ public class CLI {
public static void main(final String[] _args) throws Exception {
List<String> args = Arrays.asList(_args);
URL target = new URL("http://localhost:8080/cli");
FullDuplexHttpStream con = new FullDuplexHttpStream(target);
String url = System.getenv("HUDSON_URL");
while(!args.isEmpty()) {
String head = args.get(0);
if(head.equals("-s") && args.size()>2) {
url = args.get(1);
args = args.subList(2,args.size());
continue;
}
break;
}
if(url==null)
printUsageAndExit(Messages.CLI_NoURL());
if(args.isEmpty())
args = Arrays.asList("help"); // default to help
FullDuplexHttpStream con = new FullDuplexHttpStream(new URL(url));
ExecutorService pool = Executors.newCachedThreadPool();
Channel channel = new Channel("Chunked connection to "+target,
Channel channel = new Channel("Chunked connection to "+url,
pool,con.getInputStream(),con.getOutputStream());
// execute the command
......@@ -54,7 +71,7 @@ public class CLI {
try {
CliEntryPoint cli = (CliEntryPoint)channel.getRemoteProperty(CliEntryPoint.class.getName());
if(cli.protocolVersion()!=CliEntryPoint.VERSION) {
System.err.println("Version mismatch. This CLI cannot work with this Hudson server");
System.err.println(Messages.CLI_VersionMismatch());
} else {
r = cli.main(args, Locale.getDefault(), new RemoteInputStream(System.in),
new RemoteOutputStream(System.out), new RemoteOutputStream(System.err));
......@@ -66,4 +83,10 @@ public class CLI {
System.exit(r);
}
private static void printUsageAndExit(String msg) {
if(msg!=null) System.out.println(msg);
System.err.println(Messages.CLI_Usage());
System.exit(-1);
}
}
CLI.Usage=Hudson CLI\n\
Usage: java -jar hudson-cli.jar [-s URL] command [opts...] args...\n\
Options:\n\
\ -s URL : specify the server URL (defaults to the HUDSON_URL env var)\n\
\n\
The available commands depend on the server. Run the 'help' command to\n\
see the list.
CLI.NoURL=Neither -s nor the HUDSON_URL env var is specified.
CLI.VersionMismatch=Version mismatch. This CLI cannot work with this Hudson server
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册