Contents

Declare the command using the command extension point

First, the plugin must be dependent on the org.eclipse.buckminster.cmdline plugin in order to see the extension point. Use the plugin manifest editor to add this dependency.

Now you can select the Extensions tab, and add the extension point org.eclipse.buckminster.cmdline.command. This extension point can describe multiple commands; right click and select 'New > command'. To the right you will see the possible things you can set for the command. If you wish, you may change the class name, but it is not necessary - here we will use 'HWCommand'. Set the 'name' attribute to 'helloworld'. The others can be left to the default.

Implement the command

Click on the 'class*' attribute name - this will open New Java Class dialog. Note that the super class is set to org.eclipse.buckminster.cmdline.AbstractCommand. You don't need any method stubs (you may uncheck those boxes). Now click Finish and you will end up with a new class somewhat like this:

Run the command

Normally, the finished plugin will be installed into a Buckminster product, or be part of an Eclipse IDE installation together with the Buckminster plugins. This will make it easy to start the command using the command line (e.g. 'buckminster helloworld').

However, as you're in this case in a development mode, you want to run the command in the 'self-hosting' mode in order to enable debugging etc. However, this bypasses some activity that normally is done by the Buckminster launcher (see the description on booting), and hence we have to manually prepare a 'cmdline' file.

First, create a file called 'helloworld.cmdline'. This file is essentially a command line, but with each distinct argument on a line by itself. For convenience, it can also accept comments:

# helloworld.cmdline - for testing the helloworld command
helloworld

Now, you have to create a launch configuration to use this. Use 'Run/Run...' to open the launch configurations dialog. You want to create an 'Eclipse application'. The name isn't important. However, in 'Program to run', it must select the product org.eclipse.buckminster.headless.product. Also, on the tab 'Arguments', pass in the path and name of the cmdline file you created.

Running this configuration should print 'Hello world' in a Console view.

Adding an alias

Open the plugin manifest and activate the command extension point for helloworld. Right click on it and add an alias - for example 'hw'.
Now you can interchangeably use either 'helloworld' or 'hw' to run your command.

Adding help text

Change the cmdline file, adding a request for help:

# helloworld.cmdline - for testing the helloworld command
hw
-?

Running the command now will just declare:

Help missing for HWPlugin.helloworld

The framework has recognized the -? option but can't find the help text. Add a file called HWCommand.help alongside your java file prints out: