package brooklyn.cli.commands;

import com.google.common.base.Objects;
import com.sun.jersey.api.client.Client;
import org.codehaus.jackson.map.ObjectMapper;
import org.iq80.cli.Help;
import org.iq80.cli.Option;
import org.iq80.cli.OptionType;

import javax.inject.Inject;
import java.util.concurrent.Callable;

public abstract class BrooklynCommand implements Callable<Void> {

    public static final Client httpClient = Client.create(); // Jersey rest client
    public static final ObjectMapper jsonParser = new ObjectMapper(); // Jackson json parser

    @Option(type = OptionType.GLOBAL,
            name = { "--embedded" },
            description = "Start a simple embedded local web server")
    public boolean embedded = false;

    @Option(type = OptionType.GLOBAL,
            name = { "--endpoint" },
            description = "REST endpoint, default \"http://localhost:8080\"")
    public String endpoint = "http://localhost:8080";

    @Option(type = OptionType.GLOBAL,
            name = { "--retry" },
            description = "Will retry connection to the endpoint for this time period, default \"30s\"")
    public int retry = 30;

    @Option(type = OptionType.GLOBAL,
            name = { "--no-retry" },
            description = "Won't retry connection")
    public boolean noRetry = false;

    @Override
    public String toString() {
        return Objects.toStringHelper(getClass())
                .add("embedded", embedded)
                .add("endpoint", endpoint)
                .toString();
    }

}


@@ -155,34 +155,8 @@
 er;%0A
-import org.iq80.cli.Help;%0A
 impo
@@ -214,37 +214,8 @@
 ype;
-%0A%0Aimport javax.inject.Inject;
 %0Aimp
@@ -494,16 +494,147 @@
 parser%0A%0A
+    public static final int DEFAULT_RETRY_PERIOD = 30;%0A    public static final String DEFAULT_ENDPOINT = %22http://localhost:8080%22;%0A%0A
     @Opt
@@ -935,37 +935,36 @@
 fault %5C%22
-http://localhost:8080
+%22+DEFAULT_ENDPOINT+%22
 %5C%22%22)%0A   
@@ -989,39 +989,32 @@
 point = 
-%22http://localhost:8080%22
+DEFAULT_ENDPOINT
 ;%0A%0A    @
@@ -1177,18 +1177,40 @@
 fault %5C%22
-30
+%22+DEFAULT_RETRY_PERIOD+%22
 s%5C%22%22)%0A  
@@ -1230,18 +1230,36 @@
 retry = 
-30
+DEFAULT_RETRY_PERIOD
 ;%0A%0A    @

Extract some constants