in odps-console-xflow/src/main/java/com/aliyun/openservices/odps/console/xflow/DescribeOfflineModelCommand.java [108:157]
public static DescribeOfflineModelCommand parse(String cmd, ExecutionContext ctx)
throws ODPSConsoleException {
if (cmd == null || ctx == null) {
return null;
}
Matcher m = PATTERN.matcher(cmd);
boolean match = m.matches();
if (!match) {
return null;
}
String input = m.group(2);
String[] inputs = new AntlrObject(input).getTokenStringArray();
CommandLine commandLine = getCommandLine(inputs);
String projectName = null;
if (commandLine.hasOption("p")) {
projectName = commandLine.getOptionValue("p");
}
if (commandLine.getArgList().size() != 1) {
throw new ODPSConsoleException(ODPSConsoleConstants.BAD_COMMAND + "Model name not found.");
}
String modelName = commandLine.getArgs()[0];
if (!modelName.matches("[.\\w]+")) {
throw new ODPSConsoleException(ODPSConsoleConstants.BAD_COMMAND + "Invalid model name.");
}
if (modelName.contains(".")) {
String[] result = modelName.split("\\.", 2);
if (projectName != null && (!result[0].equals(projectName))) {
throw new ODPSConsoleException(ODPSConsoleConstants.BAD_COMMAND + "Project name conflict.");
}
projectName = result[0];
modelName = result[1];
}
if (projectName == null) {
projectName = ctx.getProjectName();
}
return new DescribeOfflineModelCommand(projectName, modelName, cmd, ctx);
}