-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
4,360 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
apply plugin: 'java' | ||
apply plugin: 'eclipse' | ||
|
||
version = '2.0.2' | ||
|
||
sourceCompatibility = '1.7' | ||
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8' | ||
|
||
if (!hasProperty('mainClass')) { | ||
ext.mainClass = 'com.crowdin.cli.Cli' | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
testCompile group: 'junit', name: 'junit', version: '4.10' | ||
compile group: 'org.json', name: 'json', version: '20160212' | ||
compile files('libs/crowdin-java-sdk-0.1.jar') | ||
compile group: 'commons-cli', name: 'commons-cli', version: '1.3.1' | ||
compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.5' | ||
compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.5' | ||
compile group: 'org.yaml', name: 'snakeyaml', version: '1.17' | ||
compile group: 'commons-io', name: 'commons-io', version: '2.5' | ||
compile group: 'com.sun.jersey', name: 'jersey-client', version: '1.19.1' | ||
compile group: 'com.sun.jersey.contribs', name: 'jersey-multipart', version: '1.19.1' | ||
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.4' | ||
compile group: 'net.lingala.zip4j', name: 'zip4j', version: '1.3.2' | ||
} | ||
|
||
task fatJar(type: Jar) { | ||
manifest { | ||
attributes 'Implementation-Title': 'Crowdin CLI', | ||
'Implementation-Version': version, | ||
'Main-Class': 'com.crowdin.cli.Cli' | ||
} | ||
baseName = 'crowdin-cli' | ||
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } | ||
with jar | ||
} |
Binary file not shown.
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 @@ | ||
rootProject.name = 'CrowdinCLI2' |
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,158 @@ | ||
package com.crowdin.cli; | ||
|
||
import com.crowdin.Credentials; | ||
import com.crowdin.cli.commands.CrowdinCliOptions; | ||
import com.crowdin.cli.properties.CliProperties; | ||
import com.crowdin.cli.properties.PropertiesBean; | ||
import com.crowdin.cli.utils.*; | ||
import org.json.JSONArray; | ||
import org.json.JSONObject; | ||
|
||
import javax.ws.rs.core.HttpHeaders; | ||
import java.io.File; | ||
import java.util.HashMap; | ||
import java.util.ResourceBundle; | ||
|
||
/** | ||
* Created by ihor on 12/1/16. | ||
*/ | ||
public class BaseCli { | ||
|
||
protected static final String FILE_NAME_IDENTITY_CROWDIN_YAML = ".crowdin.yaml"; | ||
|
||
protected static final String FILE_NAME_IDENTITY_CROWDIN_YML = ".crowdin.yml"; | ||
|
||
protected static final String OPTION_NAME_IDENTITY = "identity"; | ||
|
||
protected static final String PATH_SEPARATOR = (Utils.isWindows()) ? File.separator + File.separator : File.separator; | ||
|
||
protected static final ResourceBundle RESOURCE_BUNDLE = MessageSource.RESOURCE_BUNDLE; | ||
|
||
protected static final String STRING_PLUS = "+"; | ||
|
||
protected static final String HEADER_ACCEPT = HttpHeaders.ACCEPT; | ||
|
||
protected static final String HEADER_ACCAEPT_VALUE = "application/json"; | ||
|
||
protected static final String HEADER_CLI_VERSION = "X-CLI-VERSION"; | ||
|
||
protected static final String HEADER_CLI_VERSION_VALUE = Utils.getAppVersion(); | ||
|
||
protected static final String HEADER_JAVA_VERSION = "X-JAVA-VERSION"; | ||
|
||
protected static final String HEADER_JAVA_VERSION_VALUE = System.getProperty("java.version"); | ||
|
||
protected static final String HEADER_USER_AGENT = HttpHeaders.USER_AGENT; | ||
|
||
protected static final String HEADER_USER_AGENT_VALUE = Utils.getUserAgent(); | ||
|
||
protected static final String COMMAND_BRANCH_LONG = "branch"; | ||
|
||
protected static final String COMMAND_BRANCH_SHORT = "b"; | ||
|
||
protected static final String COMMAND_LANGUAGE_LONG = "language"; | ||
|
||
protected static final String COMMAND_LANGUAGE_SHORT = "l"; | ||
|
||
protected static final String COMMAND_NO_AUTO_UPDATE = "no-auto-update"; | ||
|
||
protected static final String PLACEHOLDER_ANDROID_CODE = "%android_code%"; | ||
|
||
protected static final String PLACEHOLDER_FILE_EXTENTION = "%file_extension%"; | ||
|
||
protected static final String PLACEHOLDER_FILE_NAME = "%file_name%"; | ||
|
||
protected static final String PLACEHOLDER_LANGUAGE = "%language%"; | ||
|
||
protected static final String PLACEHOLDER_LOCALE = "%locale%"; | ||
|
||
protected static final String PLACEHOLDER_LOCALE_WITH_UNDERSCORE = "%locale_with_underscore%"; | ||
|
||
protected static final String PLACEHOLDER_THREE_LETTERS_CODE = "%three_letters_code%"; | ||
|
||
protected static final String PLACEHOLDER_TWO_LETTERS_CODE = "%two_letters_code%"; | ||
|
||
protected static final String PLACEHOLDER_OSX_CODE = "%osx_code%"; | ||
|
||
protected static final String PLACEHOLDER_ORIGINAL_FILE_NAME = "%original_file_name%"; | ||
|
||
protected static final String PLACEHOLDER_ORIGINAL_PATH = "%original_path%"; | ||
|
||
protected static final String IGNORE_MATCH = "ignore-match"; | ||
|
||
protected static final String COMMAND_TREE = "tree"; | ||
|
||
protected static final String DESTINATION_LONG = "destination"; | ||
|
||
protected static final String DESTINATION_SHORT = "d"; | ||
|
||
protected static final String DOWNLOAD = "download"; | ||
|
||
protected static final String DOWNLOAD_TRANSLATIONS = "download translations"; | ||
|
||
protected static final String GENERATE = "generate"; | ||
|
||
protected static final String HELP = "help"; | ||
|
||
protected static final String HELP_C = "c"; | ||
|
||
protected static final String HELP_SHORT = "h"; | ||
|
||
protected static final String HELP_UPLOAD = "help upload"; | ||
|
||
protected static final String HELP_UPLOAD_SOURCES = "help upload sources"; | ||
|
||
protected static final String HELP_UPLOAD_TRANSLATIONS = "help upload translations"; | ||
|
||
protected static final String HELP_DOWNLOAD = "help download"; | ||
|
||
protected static final String HELP_GENERATE = "help generate"; | ||
|
||
protected static final String HELP_LIST = "help list"; | ||
|
||
protected static final String HELP_LIST_PROJECT = "help list project"; | ||
|
||
protected static final String HELP_LIST_SOURCES = "help list sources"; | ||
|
||
protected static final String HELP_LIST_TRANSLATIONS = "help list translations"; | ||
|
||
protected static final String HELP_HELP = "help help"; | ||
|
||
protected static final String HELP_LINT = "help lint"; | ||
|
||
protected static final String LINT = "lint"; | ||
|
||
protected static final String LIST = "list"; | ||
|
||
protected static final String LIST_PROJECT = "list project"; | ||
|
||
protected static final String LIST_SOURCES = "list sources"; | ||
|
||
protected static final String LIST_TRANSLATIONS = "list translations"; | ||
|
||
protected static final String RESPONSE_CODE = "code"; | ||
|
||
protected static final String RESPONSE_ERROR = "error"; | ||
|
||
protected static final String RESPONSE_MESSAGE = "message"; | ||
|
||
protected static final String RESPONSE_STATUS = "status"; | ||
|
||
protected static final String RESPONSE_SUCCESS = "success"; | ||
|
||
protected static final String UPLOAD = "upload"; | ||
|
||
protected static final String UPLOAD_SOURCES = "upload sources"; | ||
|
||
protected static final String UPLOAD_TRANSLATIONS = "upload translations"; | ||
|
||
protected static final String SOURCES = "sources"; | ||
|
||
protected static final String TRANSLATIONS = "translations"; | ||
|
||
protected static final String PROJECT = "project"; | ||
|
||
protected static final String OK = "OK"; | ||
|
||
protected static final String SKIPPED = "SKIPPED"; | ||
} |
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,23 @@ | ||
package com.crowdin.cli; | ||
|
||
import com.crowdin.cli.commands.Commands; | ||
import com.crowdin.cli.commands.CrowdinCliCommands; | ||
import com.crowdin.cli.commands.CrowdinCliOptions; | ||
import org.apache.commons.cli.*; | ||
|
||
public class Cli { | ||
|
||
public static void main(String[] args) { | ||
try { | ||
Options options = new CrowdinCliOptions().init(); | ||
CommandLineParser parser = new DefaultParser(); | ||
CommandLine commandLine = parser.parse(options, args); | ||
String command = new CrowdinCliCommands().init(commandLine); | ||
Commands c = new Commands(); | ||
c.run(command, commandLine); | ||
} catch (Exception e) { | ||
System.out.println("Error: " + e.getMessage()); | ||
System.exit(0); | ||
} | ||
} | ||
} |
Oops, something went wrong.