diff --git a/common/pom.xml b/common/pom.xml index 078a785a..72376080 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -54,6 +54,11 @@ limitations under the License. commons-lang + + commons-cli + commons-cli + + com.google.guava guava diff --git a/common/src/main/java/org/apache/sqoop/cli/SqoopGnuParser.java b/common/src/main/java/org/apache/sqoop/cli/SqoopGnuParser.java new file mode 100644 index 00000000..41ebdabc --- /dev/null +++ b/common/src/main/java/org/apache/sqoop/cli/SqoopGnuParser.java @@ -0,0 +1,41 @@ +/** + * 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.sqoop.cli; + +import java.util.ListIterator; + +import org.apache.commons.cli.GnuParser; +import org.apache.commons.cli.ParseException; + +public class SqoopGnuParser extends GnuParser { + public SqoopGnuParser() { + super(); + } + + @SuppressWarnings("rawtypes") + @Override + protected void processOption(final String arg, final ListIterator iter) throws ParseException { + boolean hasOption = getOptions().hasOption(arg); + + if (hasOption) { + super.processOption(arg, iter); + } else { + throw new ParseException("Unknown option encountered: " + arg); + } + } +} diff --git a/shell/pom.xml b/shell/pom.xml index 1949a8e7..6f6cf6c7 100644 --- a/shell/pom.xml +++ b/shell/pom.xml @@ -45,16 +45,6 @@ limitations under the License. org.apache.sqoop sqoop-client - - commons-cli - commons-cli - ${commons-cli.version} - - - commons-lang - commons-lang - ${commons-lang.version} - jline jline diff --git a/shell/src/main/java/org/apache/sqoop/shell/SqoopFunction.java b/shell/src/main/java/org/apache/sqoop/shell/SqoopFunction.java index 0845d8e6..3f1abcbd 100644 --- a/shell/src/main/java/org/apache/sqoop/shell/SqoopFunction.java +++ b/shell/src/main/java/org/apache/sqoop/shell/SqoopFunction.java @@ -44,7 +44,7 @@ public boolean validateArgs(CommandLine line) { } public Object execute(List args) { - CommandLine line = ConfigOptions.parseOptions(this, 1, args, true); + CommandLine line = ConfigOptions.parseOptions(this, 1, args, false); try { if (validateArgs(line)) { diff --git a/shell/src/main/java/org/apache/sqoop/shell/utils/ConfigOptions.java b/shell/src/main/java/org/apache/sqoop/shell/utils/ConfigOptions.java index 97b6e3b5..ff475419 100644 --- a/shell/src/main/java/org/apache/sqoop/shell/utils/ConfigOptions.java +++ b/shell/src/main/java/org/apache/sqoop/shell/utils/ConfigOptions.java @@ -22,11 +22,11 @@ import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.CommandLineParser; -import org.apache.commons.cli.GnuParser; import org.apache.commons.cli.Option; import org.apache.commons.cli.OptionBuilder; import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; +import org.apache.sqoop.cli.SqoopGnuParser; import org.apache.sqoop.common.SqoopException; import org.apache.sqoop.model.MConfig; import org.apache.sqoop.model.MInput; @@ -105,7 +105,7 @@ public static List