package brooklyn.cli.commands;

import brooklyn.cli.Client;
import org.iq80.cli.Command;

@Command(name = "version", description = "Print version")
public class VersionCommand extends BrooklynCommand {

    public void run() throws Exception {

        // Stub code
        // TODO: Probably need to get the server to support something like this in the REST API
        throw new UnsupportedOperationException("This command is not supported yet");

    }

}



@@ -36,56 +36,158 @@
 ort 
-brooklyn
+com.sun.jersey.api
 .cli
+ent
 .Client
-;%0Aimport org.iq80.cli.Command
+Response;%0Aimport com.sun.jersey.api.client.WebResource;%0Aimport org.iq80.cli.Command;%0Aimport javax.ws.rs.core.MediaType
 ;%0A%0A@
@@ -355,208 +355,528 @@
  // 
-Stub code%0A        // TODO: Probably need to get the server to support something like this in the REST API%0A        throw new UnsupportedOperationException(%22This command is not supported yet%22
+Make an HTTP request to the REST server and get back a JSON encoded response%0A        WebResource webResource = getClient().resource(endpoint + %22/v1/version%22);%0A        ClientResponse clientResponse = webResource.accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);%0A        String jsonResponse = clientResponse.getEntity(String.class);%0A%0A        // Parse the JSON response%0A        String version = getJsonParser().readValue(jsonResponse,String.class);%0A%0A        getOut().println(%22Brooklyn version: %22+version
 );%0A
-%0A
     %7D%0A
-%0A%7D%0A
+%7D
 %0A%0A

Implement "version" command