package org.zanata.client.commands;

import java.text.MessageFormat;
import java.util.Arrays;
import java.util.List;

import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;
import org.kohsuke.args4j.OptionDef;
import org.kohsuke.args4j.spi.OptionHandler;
import org.kohsuke.args4j.spi.Parameters;
import org.kohsuke.args4j.spi.Setter;

/**
 * Boolean {@link OptionHandler}.
 *
 * @author Kohsuke Kawaguchi
 */
public class BooleanValueHandler extends OptionHandler<Boolean> {
    private static final List<String> ACCEPTABLE_VALUES = Arrays
            .asList(new String[] { "true", "on", "yes", "1", "false", "off",
                    "no", "0" });

    public BooleanValueHandler(CmdLineParser parser, OptionDef option,
            Setter<? super Boolean> setter) {
        super(parser, option, setter);
    }

    @Override
    public int parseArguments(Parameters params) throws CmdLineException {
        String valueStr = params.getParameter(0).toLowerCase();
        int index = ACCEPTABLE_VALUES.indexOf(valueStr);
        if (index == -1) {
            throw new CmdLineException(MessageFormat.format(
                    "\"{0}\" is not a legal boolean value", valueStr));
        }
        setter.addValue(index < ACCEPTABLE_VALUES.size() / 2);
        return 1;
    }

    @Override
    public String getDefaultMetaVariable() {
        return "BOOL";
    }
}

@@ -41,81 +41,41 @@
 ort 
-java.text.MessageFormat;%0Aimport java.util.Arrays;%0Aimport java.util.List;%0A
+org.kohsuke.args4j.CmdLineParser;
 %0Aimp
@@ -97,32 +97,25 @@
 .args4j.
-CmdLineExce
+O
 ption
+Def
 ;%0Aimport
@@ -130,35 +130,46 @@
 suke.args4j.
-CmdLinePars
+spi.BooleanOptionHandl
 er;%0Aimport o
@@ -182,33 +182,56 @@
 suke.args4j.
-OptionDef
+spi.ExplicitBooleanOptionHandler
 ;%0Aimport org
@@ -269,50 +269,8 @@
 er;%0A
-import org.kohsuke.args4j.spi.Parameters;%0A
 impo
@@ -344,911 +344,331 @@
 ler%7D
-.%0A *%0A * @author Kohsuke Kawaguchi%0A */%0Apublic class BooleanValueHandler extends OptionHandler%3CBoolean%3E %7B%0A    private static final List%3CString%3E ACCEPTABLE_VALUES = Arrays%0A            .asList(new String%5B%5D %7B %22true%22, %22on%22, %22yes%22, %221%22, %22false%22, %22off%22,%0A                    %22no%22, %220%22 %7D);%0A%0A    public BooleanValueHandler(CmdLineParser parser, OptionDef option,%0A            Setter%3C? super Boolean%3E setter) %7B%0A        super(parser, option, setter);%0A    %7D%0A%0A    @Override%0A    public int parseArguments(Parameters params) throws CmdLineException %7B%0A        String valueStr = params.getParameter(0).toLowerCase();%0A        int index = ACCEPTABLE_VALUES.indexOf(valueStr);%0A        if (index == -1) %7B%0A            throw new CmdLineException(MessageFormat.format(%0A                    %22%5C%22%7B0%7D%5C%22 is not a legal boolean value%22, valueStr));%0A        %7D%0A        setter.addValue(index %3C ACCEPTABLE_VALUES.size() / 2);%0A        return 1
+ which takes an argument.  Overrides the%0A * superclass with a better default meta variable.%0A */%0Apublic class BooleanValueHandler extends ExplicitBooleanOptionHandler %7B%0A%0A    public BooleanValueHandler(CmdLineParser parser, OptionDef option,%0A            Setter%3C? super Boolean%3E setter) %7B%0A        super(parser, option, setter)
 ;%0A  

Simplify BooleanValueHandler by using ExplicitBooleanOptionHandler