]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.cms.cli/src/org/argeo/cms/cli/EventCommands.java
1 package org
.argeo
.cms
.cli
;
6 import org
.apache
.commons
.cli
.CommandLine
;
7 import org
.apache
.commons
.cli
.Options
;
8 import org
.argeo
.api
.cli
.CommandArgsException
;
9 import org
.argeo
.api
.cli
.CommandsCli
;
10 import org
.argeo
.api
.cli
.DescribedCommand
;
11 import org
.argeo
.cms
.client
.WebSocketEventClient
;
13 /** Commands dealing with CMS events. */
14 public class EventCommands
extends CommandsCli
{
15 public EventCommands(String commandName
) {
17 addCommand("listen", new EventListent());
21 public String
getDescription() {
22 return "Utilities related to an Argeo CMS";
25 class EventListent
implements DescribedCommand
<Void
> {
28 public Options
getOptions() {
29 Options options
= new Options();
30 options
.addOption(CmsCommands
.connectOption
);
35 public Void
apply(List
<String
> t
) {
36 CommandLine line
= toCommandLine(t
);
37 List
<String
> remaining
= line
.getArgList();
38 if (remaining
.size() == 0) {
39 throw new CommandArgsException("There must be at least one argument");
41 String topic
= remaining
.get(0);
43 String uriArg
= line
.getOptionValue(CmsCommands
.connectOption
);
44 // TODO make it more robust (trailing /, etc.)
45 URI uri
= URI
.create(uriArg
);
46 if ("".equals(uri
.getPath())) {
47 uri
= URI
.create(uri
.toString() + "/cms/status/event/" + topic
);
49 new WebSocketEventClient(uri
).run();
54 public String
getUsage() {
59 public String
getDescription() {
60 return "Listen to events on a topic";