|
| 1 | +/* |
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one or more |
| 3 | + * contributor license agreements. See the NOTICE file distributed with |
| 4 | + * this work for additional information regarding copyright ownership. |
| 5 | + * The ASF licenses this file to You under the Apache License, Version 2.0 |
| 6 | + * (the "License"); you may not use this file except in compliance with |
| 7 | + * the License. You may obtain a copy of the License at |
| 8 | + * |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + * See the License for the specific language governing permissions and |
| 15 | + * limitations under the License. |
| 16 | + */ |
| 17 | + |
| 18 | +package org.apache.seatunnel.core.starter.seatunnel.args; |
| 19 | + |
| 20 | +import org.apache.seatunnel.common.constants.PluginType; |
| 21 | +import org.apache.seatunnel.core.starter.command.Command; |
| 22 | +import org.apache.seatunnel.core.starter.command.CommandArgs; |
| 23 | +import org.apache.seatunnel.core.starter.seatunnel.command.ConnectorCheckCommand; |
| 24 | + |
| 25 | +import com.beust.jcommander.IStringConverter; |
| 26 | +import com.beust.jcommander.Parameter; |
| 27 | +import lombok.Data; |
| 28 | +import lombok.EqualsAndHashCode; |
| 29 | + |
| 30 | +@EqualsAndHashCode(callSuper = true) |
| 31 | +@Data |
| 32 | +public class ConnectorCheckCommandArgs extends CommandArgs { |
| 33 | + @Parameter( |
| 34 | + names = {"-l", "--list"}, |
| 35 | + description = "List all supported plugins(sources, sinks, transforms)") |
| 36 | + private boolean listConnectors = false; |
| 37 | + |
| 38 | + @Parameter( |
| 39 | + names = {"-o", "--option-rule"}, |
| 40 | + description = |
| 41 | + "Get option rule of the plugin by the plugin identifier(connector name or transform name)") |
| 42 | + private String pluginIdentifier; |
| 43 | + |
| 44 | + @Parameter( |
| 45 | + names = {"-pt", "--plugin-type"}, |
| 46 | + description = "SeaTunnel plugin type, support [source, sink, transform]", |
| 47 | + converter = SeaTunnelPluginTypeConverter.class) |
| 48 | + private PluginType pluginType; |
| 49 | + |
| 50 | + @Override |
| 51 | + public Command<?> buildCommand() { |
| 52 | + return new ConnectorCheckCommand(this); |
| 53 | + } |
| 54 | + |
| 55 | + public static class SeaTunnelPluginTypeConverter implements IStringConverter<PluginType> { |
| 56 | + @Override |
| 57 | + public PluginType convert(String value) { |
| 58 | + try { |
| 59 | + return PluginType.valueOf(value.toUpperCase()); |
| 60 | + } catch (IllegalArgumentException e) { |
| 61 | + throw new IllegalArgumentException( |
| 62 | + "The plugin type of seaTunnel only " |
| 63 | + + "support these options: [source, transform, sink]"); |
| 64 | + } |
| 65 | + } |
| 66 | + } |
| 67 | +} |
0 commit comments