com.qiniu.entry.EntryMain Maven / Gradle / Ivy
package com.qiniu.entry;
import com.qiniu.config.ParamsConfig;
import com.qiniu.config.PropertiesFile;
import com.qiniu.interfaces.IDataSource;
import com.qiniu.datasource.InputSource;
import com.qiniu.interfaces.IEntryParam;
import com.qiniu.interfaces.ILineProcess;
import com.qiniu.util.*;
import java.io.File;
import java.io.IOException;
import java.util.*;
public class EntryMain {
// 如果不希望对危险 process 进行 verify,请将该参数设置为 false
public static boolean processVerify = true;
@SuppressWarnings("unchecked")
public static void main(String[] args) throws Exception {
Map preSetMap = new HashMap(){{
put("f", "verify=false");
put("s", "single=true");
put("single", "single=true");
put("line", "single=true");
put("i", "interactive=true");
put("interactive", "interactive=true");
put("d", "default=true"); // for default account setting
put("getaccount", "getaccount=default"); // for default account query
put("dis", "displayed=false"); // get default account without displayed secret
put("key=", ""); // get default account without displayed secret
put("to-key=", ""); // get default account without displayed secret
}};
Map paramsMap = getEntryParams(args, preSetMap);
IEntryParam entryParam = new ParamsConfig(paramsMap);
if (paramsMap.containsKey("account")) {
String accountName = paramsMap.get("account");
if (!accountName.contains("-")) accountName = String.join("-", "qiniu", accountName);
AccountUtils.setAccount(entryParam, accountName);
List keysList = AccountUtils.getAccount(accountName, true);
for (String[] keys : keysList) {
System.out.println(keys[2] + ": ");
System.out.println("id: " + keys[0]);
System.out.println("secret: " + keys[1]);
}
return;
} else if (paramsMap.containsKey("getaccount")) {
boolean implicit = !paramsMap.containsKey("displayed");
String accountName = paramsMap.get("getaccount");
if ("default".equals(accountName)) {
if (entryParam.getValue("default", "false").equals("true")) accountName = null;
else throw new IOException("please set account name or use \"-d\"");
}
List keysList = AccountUtils.getAccount(accountName, implicit);
for (String[] keys : keysList) {
System.out.println(keys[2] + ": ");
System.out.println("id: " + keys[0]);
System.out.println("secret: " + keys[1]);
}
return;
} else if (paramsMap.containsKey("delaccount")) {
AccountUtils.deleteAccount(paramsMap.get("delaccount"));
return;
}
if (paramsMap.containsKey("verify")) processVerify = Boolean.parseBoolean(paramsMap.get("verify"));
boolean single = paramsMap.containsKey("single") && Boolean.parseBoolean(paramsMap.get("single"));
boolean interactive = paramsMap.containsKey("interactive") && Boolean.parseBoolean(paramsMap.get("interactive"));
CommonParams commonParams = single ? new CommonParams(paramsMap) : new CommonParams(entryParam);
QSuitsEntry qSuitsEntry = new QSuitsEntry(entryParam, commonParams);
ILineProcess
© 2015 - 2024 Weber Informatics LLC | Privacy Policy