Skip to content

Commit 7b08a30

Browse files
authored
Update README.md
1 parent 26f2963 commit 7b08a30

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,30 @@ A short description can also be accessed directly from the gogo shell by typing
2121

2222
Please note that parameters like settings may be driver or device specific. As the channels configuration may
2323
be set in the `channels.xml` file, no commands for editing the configuration (e.g. adding a device) are included.
24+
25+
## How to implement own Gogo commands
26+
A good tutorial for implementing own Gogo commands can be found [at this website](http://coders-kitchen.com/2012/04/06/tutorial-an-own-gogo-shell-command/). If OSGi's [declarative services](http://blog.vogella.com/2016/06/21/getting-started-with-osgi-declarative-services/) should be used, the neccessary properties `osgi.command.scope` and `osgi.command.function` must be set in the component description XML file like in the following example:
27+
28+
```xml
29+
<property name="osgi.command.scope" type="String" value="openmuc"/>
30+
<property name="osgi.command.function">
31+
channels
32+
config
33+
drivers
34+
read
35+
scanForChannels
36+
scanForDevices
37+
write
38+
</property>
39+
```
40+
41+
The property `osgi.command.function` declares the provided commands of the service component as an array of strings. The implementation function names *must* match the declared function names. As an example, the full component definition of this project can be found [here](https://github.com/openmucextensions/console/blob/master/src/main/resources/OSGI-INF/components.xml). Don't forget to provide the class that implements the commands as a service in the component definition, although no service interface has been implemented.
42+
43+
To provide information for the `help` command of Gogo, the Gogo runtime package provides the annotation `@Descriptor`, that can be used for both, methods and parameters. The following example shows the usage of the annotation:
44+
45+
```java
46+
@Descriptor("scans for devices with a specific driver")
47+
public void scanForDevices(@Descriptor("the driver id") String driverId) {
48+
// method implementation
49+
}
50+
```

0 commit comments

Comments
 (0)