]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - org/argeo/cms/cli/CmsCommands.java
1 package org
.argeo
.cms
.cli
;
6 import org
.apache
.commons
.cli
.CommandLine
;
7 import org
.argeo
.api
.cli
.CommandArgsException
;
8 import org
.argeo
.api
.cli
.CommandsCli
;
9 import org
.argeo
.api
.cli
.DescribedCommand
;
10 import org
.argeo
.cms
.client
.WsPing
;
12 public class CmsCommands
extends CommandsCli
{
14 public CmsCommands(String commandName
) {
16 addCommand("ping", new Ping());
20 public String
getDescription() {
21 return "Utilities related to an Argeo CMS";
24 class Ping
implements DescribedCommand
<Void
> {
27 public Void
apply(List
<String
> t
) {
28 CommandLine line
= toCommandLine(t
);
29 List
<String
> remaining
= line
.getArgList();
30 if (remaining
.size() == 0) {
31 throw new CommandArgsException("There must be at least one argument");
33 String uriArg
= remaining
.get(0);
34 // TODO make it more robust (trailing /, etc.)
35 URI uri
= URI
.create(uriArg
);
36 if ("".equals(uri
.getPath())) {
37 uri
= URI
.create(uri
.toString() + "/cms/status/ping");
39 new WsPing(uri
).run();
44 public String
getUsage() {
45 return "[ws|wss]://host:port/";
49 public String
getDescription() {
50 return "Test whether an Argeo CMS is available, without auhtentication";