ruanwenjun commented on code in PR #5401: URL: https://github.com/apache/seatunnel/pull/5401#discussion_r1310231053
########## seatunnel-core/seatunnel-core-starter/src/main/java/org/apache/seatunnel/core/starter/command/ParameterSplitter.java: ########## @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.seatunnel.core.starter.command; + +import com.beust.jcommander.converters.IParameterSplitter; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class ParameterSplitter implements IParameterSplitter { + + Pattern pattern = Pattern.compile("\\[.*?]|,"); + + @Override + public List<String> split(String value) { + if (!value.contains(",")) { + return Collections.singletonList(value); + } + Matcher matcher = pattern.matcher(value); + StringBuilder stringBuilder = new StringBuilder(); + int start = 0; + while (matcher.find()) { + stringBuilder.append(value, start, matcher.start()); + if (matcher.group().equals(",")) { + stringBuilder.append(";"); + } else { + stringBuilder.append(matcher.group()); + } + start = matcher.end(); + } + stringBuilder.append(value.substring(start)); // 添加剩余部分 Review Comment: ```suggestion stringBuilder.append(value.substring(start)); ``` ########## seatunnel-core/seatunnel-core-starter/src/main/java/org/apache/seatunnel/core/starter/command/ParameterSplitter.java: ########## @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.seatunnel.core.starter.command; + +import com.beust.jcommander.converters.IParameterSplitter; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class ParameterSplitter implements IParameterSplitter { + + Pattern pattern = Pattern.compile("\\[.*?]|,"); + + @Override + public List<String> split(String value) { Review Comment: Please add doc and UT for this method, and if the params contains ";" what will happen? e.g. if the args looks like -i "map = ["par1=20230829;", "par2=20230829;"]" -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
