This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Make encoding of tabs optional; pass options to PullStrategy construc…
…tors
- Loading branch information
Showing
21 changed files
with
153 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
zanata-client-commands/src/main/java/org/zanata/client/commands/BooleanValueHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| 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"; | ||
| } | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
...a-client-commands/src/main/java/org/zanata/client/commands/pull/AbstractPullStrategy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| package org.zanata.client.commands.pull; | ||
|
|
||
| public abstract class AbstractPullStrategy implements PullStrategy | ||
| { | ||
| private final PullOptions opts; | ||
|
|
||
| protected AbstractPullStrategy(PullOptions opts) | ||
| { | ||
| this.opts = opts; | ||
| } | ||
|
|
||
| public PullOptions getOpts() | ||
| { | ||
| return opts; | ||
| } | ||
|
|
||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.