From 63883b3112d74f7f69b0886ff3f3314bfcb0a5e0 Mon Sep 17 00:00:00 2001 From: Philipp Wollermann Date: Wed, 18 Jul 2018 13:21:48 +0200 Subject: Remove jopt-simple from third_party --- third_party/BUILD | 1 - third_party/java/jopt-simple/BUILD | 17 - third_party/java/jopt-simple/LICENSE.txt | 24 - third_party/java/jopt-simple/README.bazel.md | 7 - third_party/java/jopt-simple/README.md | 7 - .../jopt-simple/jopt-simple-eclipse-formatting.xml | 283 --------- .../java/jopt-simple/jopt-simple.importorder | 8 - third_party/java/jopt-simple/paste-examples.xml | 205 ------- third_party/java/jopt-simple/pom.xml | 342 ----------- .../main/java/joptsimple/AbstractOptionSpec.java | 148 ----- .../java/joptsimple/AlternativeLongOptionSpec.java | 65 --- .../joptsimple/ArgumentAcceptingOptionSpec.java | 329 ----------- .../src/main/java/joptsimple/ArgumentList.java | 59 -- .../main/java/joptsimple/BuiltinHelpFormatter.java | 565 ------------------ .../src/main/java/joptsimple/HelpFormatter.java | 45 -- .../IllegalOptionSpecificationException.java | 46 -- .../MissingRequiredOptionsException.java | 46 -- .../MultipleArgumentsForOptionException.java | 46 -- .../main/java/joptsimple/NoArgumentOptionSpec.java | 81 --- .../java/joptsimple/NonOptionArgumentSpec.java | 170 ------ .../OptionArgumentConversionException.java | 50 -- .../src/main/java/joptsimple/OptionDeclarer.java | 116 ---- .../src/main/java/joptsimple/OptionDescriptor.java | 100 ---- .../src/main/java/joptsimple/OptionException.java | 125 ---- .../OptionMissingRequiredArgumentException.java | 46 -- .../src/main/java/joptsimple/OptionParser.java | 647 --------------------- .../main/java/joptsimple/OptionParserState.java | 76 --- .../src/main/java/joptsimple/OptionSet.java | 325 ----------- .../src/main/java/joptsimple/OptionSpec.java | 97 --- .../main/java/joptsimple/OptionSpecBuilder.java | 275 --------- .../main/java/joptsimple/OptionSpecTokenizer.java | 126 ---- .../joptsimple/OptionalArgumentOptionSpec.java | 69 --- .../src/main/java/joptsimple/ParserRules.java | 84 --- .../joptsimple/RequiredArgumentOptionSpec.java | 52 -- .../joptsimple/UnavailableOptionException.java | 45 -- .../joptsimple/UnconfiguredOptionException.java | 52 -- .../joptsimple/UnrecognizedOptionException.java | 46 -- .../java/joptsimple/ValueConversionException.java | 54 -- .../src/main/java/joptsimple/ValueConverter.java | 58 -- .../java/joptsimple/internal/AbbreviationMap.java | 242 -------- .../src/main/java/joptsimple/internal/Classes.java | 75 --- .../src/main/java/joptsimple/internal/Columns.java | 106 ---- .../ConstructorInvokingValueConverter.java | 56 -- .../main/java/joptsimple/internal/Messages.java | 47 -- .../internal/MethodInvokingValueConverter.java | 58 -- .../java/joptsimple/internal/OptionNameMap.java | 47 -- .../main/java/joptsimple/internal/Reflection.java | 142 ----- .../joptsimple/internal/ReflectionException.java | 39 -- .../src/main/java/joptsimple/internal/Row.java | 55 -- .../src/main/java/joptsimple/internal/Rows.java | 103 ---- .../joptsimple/internal/SimpleOptionNameMap.java | 67 --- .../src/main/java/joptsimple/internal/Strings.java | 115 ---- .../main/java/joptsimple/util/DateConverter.java | 114 ---- .../main/java/joptsimple/util/EnumConverter.java | 104 ---- .../java/joptsimple/util/InetAddressConverter.java | 67 --- .../main/java/joptsimple/util/KeyValuePair.java | 83 --- .../main/java/joptsimple/util/PathConverter.java | 51 -- .../main/java/joptsimple/util/PathProperties.java | 60 -- .../main/java/joptsimple/util/RegexMatcher.java | 95 --- .../joptsimple/ExceptionMessages.properties | 19 - .../joptsimple/HelpFormatterMessages.properties | 11 - 61 files changed, 6693 deletions(-) delete mode 100644 third_party/java/jopt-simple/BUILD delete mode 100644 third_party/java/jopt-simple/LICENSE.txt delete mode 100644 third_party/java/jopt-simple/README.bazel.md delete mode 100644 third_party/java/jopt-simple/README.md delete mode 100644 third_party/java/jopt-simple/jopt-simple-eclipse-formatting.xml delete mode 100644 third_party/java/jopt-simple/jopt-simple.importorder delete mode 100644 third_party/java/jopt-simple/paste-examples.xml delete mode 100644 third_party/java/jopt-simple/pom.xml delete mode 100644 third_party/java/jopt-simple/src/main/java/joptsimple/AbstractOptionSpec.java delete mode 100644 third_party/java/jopt-simple/src/main/java/joptsimple/AlternativeLongOptionSpec.java delete mode 100644 third_party/java/jopt-simple/src/main/java/joptsimple/ArgumentAcceptingOptionSpec.java delete mode 100644 third_party/java/jopt-simple/src/main/java/joptsimple/ArgumentList.java delete mode 100644 third_party/java/jopt-simple/src/main/java/joptsimple/BuiltinHelpFormatter.java delete mode 100644 third_party/java/jopt-simple/src/main/java/joptsimple/HelpFormatter.java delete mode 100644 third_party/java/jopt-simple/src/main/java/joptsimple/IllegalOptionSpecificationException.java delete mode 100644 third_party/java/jopt-simple/src/main/java/joptsimple/MissingRequiredOptionsException.java delete mode 100644 third_party/java/jopt-simple/src/main/java/joptsimple/MultipleArgumentsForOptionException.java delete mode 100644 third_party/java/jopt-simple/src/main/java/joptsimple/NoArgumentOptionSpec.java delete mode 100644 third_party/java/jopt-simple/src/main/java/joptsimple/NonOptionArgumentSpec.java delete mode 100644 third_party/java/jopt-simple/src/main/java/joptsimple/OptionArgumentConversionException.java delete mode 100644 third_party/java/jopt-simple/src/main/java/joptsimple/OptionDeclarer.java delete mode 100644 third_party/java/jopt-simple/src/main/java/joptsimple/OptionDescriptor.java delete mode 100644 third_party/java/jopt-simple/src/main/java/joptsimple/OptionException.java delete mode 100644 third_party/java/jopt-simple/src/main/java/joptsimple/OptionMissingRequiredArgumentException.java delete mode 100644 third_party/java/jopt-simple/src/main/java/joptsimple/OptionParser.java delete mode 100644 third_party/java/jopt-simple/src/main/java/joptsimple/OptionParserState.java delete mode 100644 third_party/java/jopt-simple/src/main/java/joptsimple/OptionSet.java delete mode 100644 third_party/java/jopt-simple/src/main/java/joptsimple/OptionSpec.java delete mode 100644 third_party/java/jopt-simple/src/main/java/joptsimple/OptionSpecBuilder.java delete mode 100644 third_party/java/jopt-simple/src/main/java/joptsimple/OptionSpecTokenizer.java delete mode 100644 third_party/java/jopt-simple/src/main/java/joptsimple/OptionalArgumentOptionSpec.java delete mode 100644 third_party/java/jopt-simple/src/main/java/joptsimple/ParserRules.java delete mode 100644 third_party/java/jopt-simple/src/main/java/joptsimple/RequiredArgumentOptionSpec.java delete mode 100644 third_party/java/jopt-simple/src/main/java/joptsimple/UnavailableOptionException.java delete mode 100644 third_party/java/jopt-simple/src/main/java/joptsimple/UnconfiguredOptionException.java delete mode 100644 third_party/java/jopt-simple/src/main/java/joptsimple/UnrecognizedOptionException.java delete mode 100644 third_party/java/jopt-simple/src/main/java/joptsimple/ValueConversionException.java delete mode 100644 third_party/java/jopt-simple/src/main/java/joptsimple/ValueConverter.java delete mode 100644 third_party/java/jopt-simple/src/main/java/joptsimple/internal/AbbreviationMap.java delete mode 100644 third_party/java/jopt-simple/src/main/java/joptsimple/internal/Classes.java delete mode 100644 third_party/java/jopt-simple/src/main/java/joptsimple/internal/Columns.java delete mode 100644 third_party/java/jopt-simple/src/main/java/joptsimple/internal/ConstructorInvokingValueConverter.java delete mode 100644 third_party/java/jopt-simple/src/main/java/joptsimple/internal/Messages.java delete mode 100644 third_party/java/jopt-simple/src/main/java/joptsimple/internal/MethodInvokingValueConverter.java delete mode 100644 third_party/java/jopt-simple/src/main/java/joptsimple/internal/OptionNameMap.java delete mode 100644 third_party/java/jopt-simple/src/main/java/joptsimple/internal/Reflection.java delete mode 100644 third_party/java/jopt-simple/src/main/java/joptsimple/internal/ReflectionException.java delete mode 100644 third_party/java/jopt-simple/src/main/java/joptsimple/internal/Row.java delete mode 100644 third_party/java/jopt-simple/src/main/java/joptsimple/internal/Rows.java delete mode 100644 third_party/java/jopt-simple/src/main/java/joptsimple/internal/SimpleOptionNameMap.java delete mode 100644 third_party/java/jopt-simple/src/main/java/joptsimple/internal/Strings.java delete mode 100644 third_party/java/jopt-simple/src/main/java/joptsimple/util/DateConverter.java delete mode 100644 third_party/java/jopt-simple/src/main/java/joptsimple/util/EnumConverter.java delete mode 100644 third_party/java/jopt-simple/src/main/java/joptsimple/util/InetAddressConverter.java delete mode 100644 third_party/java/jopt-simple/src/main/java/joptsimple/util/KeyValuePair.java delete mode 100644 third_party/java/jopt-simple/src/main/java/joptsimple/util/PathConverter.java delete mode 100644 third_party/java/jopt-simple/src/main/java/joptsimple/util/PathProperties.java delete mode 100644 third_party/java/jopt-simple/src/main/java/joptsimple/util/RegexMatcher.java delete mode 100644 third_party/java/jopt-simple/src/main/resources/joptsimple/ExceptionMessages.properties delete mode 100644 third_party/java/jopt-simple/src/main/resources/joptsimple/HelpFormatterMessages.properties (limited to 'third_party') diff --git a/third_party/BUILD b/third_party/BUILD index eafa07c094..a9454b07ad 100644 --- a/third_party/BUILD +++ b/third_party/BUILD @@ -18,7 +18,6 @@ filegroup( "//third_party/java/jacoco:srcs", "//third_party/java/javapoet:srcs", "//third_party/java/jcommander:srcs", - "//third_party/java/jopt-simple:srcs", "//third_party/java/jdk/langtools:srcs", "//third_party/java/proguard:srcs", "//third_party/javascript/bootstrap:srcs", diff --git a/third_party/java/jopt-simple/BUILD b/third_party/java/jopt-simple/BUILD deleted file mode 100644 index eb145bb623..0000000000 --- a/third_party/java/jopt-simple/BUILD +++ /dev/null @@ -1,17 +0,0 @@ -package(default_visibility = ["//visibility:public"]) - -licenses(["notice"]) # MIT - -filegroup( - name = "srcs", - srcs = glob(["**"]), -) - -java_library( - name = "jopt-simple", - srcs = glob(["src/main/**/*.java"]), - resources = [ - "src/main/resources/joptsimple/ExceptionMessages.properties", - "src/main/resources/joptsimple/HelpFormatterMessages.properties", - ], -) diff --git a/third_party/java/jopt-simple/LICENSE.txt b/third_party/java/jopt-simple/LICENSE.txt deleted file mode 100644 index 85f923a952..0000000000 --- a/third_party/java/jopt-simple/LICENSE.txt +++ /dev/null @@ -1,24 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ diff --git a/third_party/java/jopt-simple/README.bazel.md b/third_party/java/jopt-simple/README.bazel.md deleted file mode 100644 index 759711bf04..0000000000 --- a/third_party/java/jopt-simple/README.bazel.md +++ /dev/null @@ -1,7 +0,0 @@ -This is jopt-simple 5.0.3. Reproduction: - -1. `git clone https://github.com/jopt-simple/jopt-simple` -2. `git checkout jopt-simple-5.0.3` (commithash `b52b94611dba126a8236a10277d15676e31ab5f6`) -3. Dump the contents of the `git` tree into `third_party/java/jopt-simple` -4. Keep the existing, trivial `BUILD` file -5. Remove the src/test and src/site directories. diff --git a/third_party/java/jopt-simple/README.md b/third_party/java/jopt-simple/README.md deleted file mode 100644 index ffe1ce208d..0000000000 --- a/third_party/java/jopt-simple/README.md +++ /dev/null @@ -1,7 +0,0 @@ -[![Build Status](https://travis-ci.org/pholser/jopt-simple.svg?branch=master)](https://travis-ci.org/pholser/jopt-simple) - -Please see http://pholser.github.com/jopt-simple for more information. - -### Discussing - -There is [a Google group for JOpt Simple](https://groups.google.com/d/forum/jopt-simple). diff --git a/third_party/java/jopt-simple/jopt-simple-eclipse-formatting.xml b/third_party/java/jopt-simple/jopt-simple-eclipse-formatting.xml deleted file mode 100644 index e4b2eb8312..0000000000 --- a/third_party/java/jopt-simple/jopt-simple-eclipse-formatting.xml +++ /dev/null @@ -1,283 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/third_party/java/jopt-simple/jopt-simple.importorder b/third_party/java/jopt-simple/jopt-simple.importorder deleted file mode 100644 index e94bb816a3..0000000000 --- a/third_party/java/jopt-simple/jopt-simple.importorder +++ /dev/null @@ -1,8 +0,0 @@ -#Organize Import Order -#Tue Oct 18 14:21:56 CDT 2011 -5=\# -4=\#javax -3=\#java -2= -1=javax -0=java diff --git a/third_party/java/jopt-simple/paste-examples.xml b/third_party/java/jopt-simple/paste-examples.xml deleted file mode 100644 index e1b6254481..0000000000 --- a/third_party/java/jopt-simple/paste-examples.xml +++ /dev/null @@ -1,205 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/third_party/java/jopt-simple/pom.xml b/third_party/java/jopt-simple/pom.xml deleted file mode 100644 index c2fc280944..0000000000 --- a/third_party/java/jopt-simple/pom.xml +++ /dev/null @@ -1,342 +0,0 @@ - - 4.0.0 - - org.sonatype.oss - oss-parent - 7 - - net.sf.jopt-simple - jopt-simple - 5.0.3 - jar - JOpt Simple - http://pholser.github.io/jopt-simple - A Java library for parsing command line options - - - The MIT License - http://www.opensource.org/licenses/mit-license.php - repo - - - - scm:git:git://github.com/pholser/jopt-simple.git - scm:git:ssh://git@github.com/pholser/jopt-simple.git - https://github.com/pholser/jopt-simple - - - GitHub - https://github.com/pholser/jopt-simple/issues - - - - pholser - Paul Holser - pholser@alumni.rice.edu - http://www.pholser.com - - - - UTF-8 - UTF-8 - UTF-8 - - - - joda-time - joda-time - 2.3 - test - - - org.apache.ant - ant - 1.8.4 - test - - - org.hamcrest - hamcrest-all - 1.3 - test - - - junit - junit - 4.12 - test - - - org.infinitest - continuous-testing-toolkit - 1.0 - test - - - org.hamcrest - hamcrest-all - - - - - - - - org.apache.maven.scm - maven-scm-provider-gitexe - 1.9.2 - - - org.apache.maven.scm - maven-scm-manager-plexus - 1.9.2 - - - org.kathrynhuxtable.maven.wagon - wagon-gitsite - 0.3.1 - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.2 - - 1.7 - 1.7 - - - - org.codehaus.mojo - animal-sniffer-maven-plugin - 1.13 - - - org.codehaus.mojo.signature - java17 - 1.0 - - - - - check-signature - - check - - - - - - - org.apache.felix - maven-bundle-plugin - 2.3.7 - true - - - ${project.groupId}.${project.artifactId} - ${project.artifactId} - ${project.version} - ${project.name} - joptsimple,joptsimple.util - joptsimple.internal - - - - - package - - bundle - - - - - - org.codehaus.mojo - cobertura-maven-plugin - 2.6 - - - true - 96 - 99 - - - - - - clean - check - - - - - - org.apache.maven.plugins - maven-pmd-plugin - 3.4 - - 40 - 1.7 - - - - compile - - cpd-check - - - - - - org.apache.maven.plugins - maven-antrun-plugin - 1.8 - - - paste-examples - post-site - - - - - - - - - - - run - - - - - - maven-site-plugin - 3.3 - - UTF-8 - - - - org.pitest - pitest-maven - 1.1.9 - - - joptsimple* - - - *Test - - - equals - hashCode - - - joptsimple.examples* - *EqualsHash*Test - *TestCase - *Fixture - *Harness - *Matchers - *Ctor - *Problematic - *ValueOfHaver - - - - - org.apache.maven.plugins - maven-source-plugin - 2.4 - - - attach-sources - package - - jar - - - - - - - - - - org.apache.maven.plugins - maven-project-info-reports-plugin - 2.8 - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.9.1 - - 1.7 - public - joptsimple.examples:joptsimple.internal:joptsimple.internal.* - - https://docs.oracle.com/javase/8/docs/api - - © Copyright 2004-2015 Paul R. Holser, Jr. All rights reserved. Licensed under The MIT License. pholser@alumni.rice.edu]]> - - - - - javadoc - - - - - - org.codehaus.mojo - cobertura-maven-plugin - 2.6 - - - true - 97 - 99 - - - xml - html - - - - - org.codehaus.mojo - findbugs-maven-plugin - 3.0.0 - - Low - - - - org.apache.maven.plugins - maven-pmd-plugin - 3.4 - - 40 - 1.7 - - - - - - - github-project-site - gitsite:git@github.com/pholser/jopt-simple.git - - - diff --git a/third_party/java/jopt-simple/src/main/java/joptsimple/AbstractOptionSpec.java b/third_party/java/jopt-simple/src/main/java/joptsimple/AbstractOptionSpec.java deleted file mode 100644 index 2c045bd500..0000000000 --- a/third_party/java/jopt-simple/src/main/java/joptsimple/AbstractOptionSpec.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import java.util.ArrayList; -import java.util.List; - -import static java.util.Collections.*; - -import joptsimple.internal.Reflection; -import joptsimple.internal.ReflectionException; - -import static joptsimple.internal.Strings.*; - -/** - * @param represents the type of the arguments this option accepts - * @author Paul Holser - */ -public abstract class AbstractOptionSpec implements OptionSpec, OptionDescriptor { - private final List options = new ArrayList<>(); - private final String description; - private boolean forHelp; - - AbstractOptionSpec( String option ) { - this( singletonList( option ), EMPTY ); - } - - AbstractOptionSpec( List options, String description ) { - arrangeOptions( options ); - - this.description = description; - } - - public final List options() { - return unmodifiableList( options ); - } - - public final List values( OptionSet detectedOptions ) { - return detectedOptions.valuesOf( this ); - } - - public final V value( OptionSet detectedOptions ) { - return detectedOptions.valueOf( this ); - } - - public String description() { - return description; - } - - public final AbstractOptionSpec forHelp() { - forHelp = true; - return this; - } - - public final boolean isForHelp() { - return forHelp; - } - - public boolean representsNonOptions() { - return false; - } - - protected abstract V convert( String argument ); - - protected V convertWith( ValueConverter converter, String argument ) { - try { - return Reflection.convertWith( converter, argument ); - } catch ( ReflectionException | ValueConversionException ex ) { - throw new OptionArgumentConversionException( this, argument, ex ); - } - } - - protected String argumentTypeIndicatorFrom( ValueConverter converter ) { - if ( converter == null ) - return null; - - String pattern = converter.valuePattern(); - return pattern == null ? converter.valueType().getName() : pattern; - } - - abstract void handleOption( OptionParser parser, ArgumentList arguments, OptionSet detectedOptions, - String detectedArgument ); - - private void arrangeOptions( List unarranged ) { - if ( unarranged.size() == 1 ) { - options.addAll( unarranged ); - return; - } - - List shortOptions = new ArrayList<>(); - List longOptions = new ArrayList<>(); - - for ( String each : unarranged ) { - if ( each.length() == 1 ) - shortOptions.add( each ); - else - longOptions.add( each ); - } - - sort( shortOptions ); - sort( longOptions ); - - options.addAll( shortOptions ); - options.addAll( longOptions ); - } - - @Override - public boolean equals( Object that ) { - if ( !( that instanceof AbstractOptionSpec ) ) - return false; - - AbstractOptionSpec other = (AbstractOptionSpec) that; - return options.equals( other.options ); - } - - @Override - public int hashCode() { - return options.hashCode(); - } - - @Override - public String toString() { - return options.toString(); - } -} diff --git a/third_party/java/jopt-simple/src/main/java/joptsimple/AlternativeLongOptionSpec.java b/third_party/java/jopt-simple/src/main/java/joptsimple/AlternativeLongOptionSpec.java deleted file mode 100644 index a3108c1da4..0000000000 --- a/third_party/java/jopt-simple/src/main/java/joptsimple/AlternativeLongOptionSpec.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import joptsimple.internal.Messages; - -import java.util.Locale; - -import static java.util.Collections.*; - -import static joptsimple.ParserRules.*; - -/** - * Represents the {@code "-W"} form of long option specification. - * - * @author Paul Holser - */ -class AlternativeLongOptionSpec extends ArgumentAcceptingOptionSpec { - AlternativeLongOptionSpec() { - super( singletonList( RESERVED_FOR_EXTENSIONS ), - true, - Messages.message( - Locale.getDefault(), - "joptsimple.HelpFormatterMessages", - AlternativeLongOptionSpec.class, - "description" ) ); - - describedAs( Messages.message( - Locale.getDefault(), - "joptsimple.HelpFormatterMessages", - AlternativeLongOptionSpec.class, - "arg.description" ) ); - } - - @Override - protected void detectOptionArgument( OptionParser parser, ArgumentList arguments, OptionSet detectedOptions ) { - if ( !arguments.hasMore() ) - throw new OptionMissingRequiredArgumentException( this ); - - arguments.treatNextAsLongOption(); - } -} diff --git a/third_party/java/jopt-simple/src/main/java/joptsimple/ArgumentAcceptingOptionSpec.java b/third_party/java/jopt-simple/src/main/java/joptsimple/ArgumentAcceptingOptionSpec.java deleted file mode 100644 index ca4c59f0b0..0000000000 --- a/third_party/java/jopt-simple/src/main/java/joptsimple/ArgumentAcceptingOptionSpec.java +++ /dev/null @@ -1,329 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import java.util.ArrayList; -import java.util.List; -import java.util.StringTokenizer; - -import static java.util.Collections.*; -import static java.util.Objects.*; - -import static joptsimple.internal.Reflection.*; -import static joptsimple.internal.Strings.*; - -/** - *

Specification of an option that accepts an argument.

- * - *

Instances are returned from {@link OptionSpecBuilder} methods to allow the formation of parser directives as - * sentences in a "fluent interface" language. For example:

- * - *
- *   
- *   OptionParser parser = new OptionParser();
- *   parser.accepts( "c" ).withRequiredArg().ofType( Integer.class );
- *   
- * 
- * - *

If no methods are invoked on an instance of this class, then that instance's option will treat its argument as - * a {@link String}.

- * - * @param represents the type of the arguments this option accepts - * @author Paul Holser - */ -public abstract class ArgumentAcceptingOptionSpec extends AbstractOptionSpec { - private static final char NIL_VALUE_SEPARATOR = '\u0000'; - - private final boolean argumentRequired; - private final List defaultValues = new ArrayList<>(); - - private boolean optionRequired; - private ValueConverter converter; - private String argumentDescription = ""; - private String valueSeparator = String.valueOf( NIL_VALUE_SEPARATOR ); - - ArgumentAcceptingOptionSpec( String option, boolean argumentRequired ) { - super( option ); - - this.argumentRequired = argumentRequired; - } - - ArgumentAcceptingOptionSpec( List options, boolean argumentRequired, String description ) { - super( options, description ); - - this.argumentRequired = argumentRequired; - } - - /** - *

Specifies a type to which arguments of this spec's option are to be converted.

- * - *

JOpt Simple accepts types that have either:

- * - *
    - *
  1. a public static method called {@code valueOf} which accepts a single argument of type {@link String} - * and whose return type is the same as the class on which the method is declared. The {@code java.lang} - * primitive wrapper classes have such methods.
  2. - * - *
  3. a public constructor which accepts a single argument of type {@link String}.
  4. - *
- * - *

This class converts arguments using those methods in that order; that is, {@code valueOf} would be invoked - * before a one-{@link String}-arg constructor would.

- * - *

Invoking this method will trump any previous calls to this method or to - * {@link #withValuesConvertedBy(ValueConverter)}.

- * - * @param represents the runtime class of the desired option argument type - * @param argumentType desired type of arguments to this spec's option - * @return self, so that the caller can add clauses to the fluent interface sentence - * @throws NullPointerException if the type is {@code null} - * @throws IllegalArgumentException if the type does not have the standard conversion methods - */ - public final ArgumentAcceptingOptionSpec ofType( Class argumentType ) { - return withValuesConvertedBy( findConverter( argumentType ) ); - } - - /** - *

Specifies a converter to use to translate arguments of this spec's option into Java objects. This is useful - * when converting to types that do not have the requisite factory method or constructor for - * {@link #ofType(Class)}.

- * - *

Invoking this method will trump any previous calls to this method or to {@link #ofType(Class)}. - * - * @param represents the runtime class of the desired option argument type - * @param aConverter the converter to use - * @return self, so that the caller can add clauses to the fluent interface sentence - * @throws NullPointerException if the converter is {@code null} - */ - @SuppressWarnings( "unchecked" ) - public final ArgumentAcceptingOptionSpec withValuesConvertedBy( ValueConverter aConverter ) { - if ( aConverter == null ) - throw new NullPointerException( "illegal null converter" ); - - converter = (ValueConverter) aConverter; - return (ArgumentAcceptingOptionSpec) this; - } - - /** - *

Specifies a description for the argument of the option that this spec represents. This description is used - * when generating help information about the parser.

- * - * @param description describes the nature of the argument of this spec's option - * @return self, so that the caller can add clauses to the fluent interface sentence - */ - public final ArgumentAcceptingOptionSpec describedAs( String description ) { - argumentDescription = description; - return this; - } - - /** - *

Specifies a value separator for the argument of the option that this spec represents. This allows a single - * option argument to represent multiple values for the option. For example:

- * - *
-     *   
-     *   parser.accepts( "z" ).withRequiredArg()
-     *       .withValuesSeparatedBy( ',' );
-     *   OptionSet options = parser.parse( new String[] { "-z", "foo,bar,baz", "-z",
-     *       "fizz", "-z", "buzz" } );
-     *   
-     * 
- * - *

Then options.valuesOf( "z" ) would yield the list {@code [foo, bar, baz, fizz, buzz]}.

- * - *

You cannot use Unicode U+0000 as the separator.

- * - * @param separator a character separator - * @return self, so that the caller can add clauses to the fluent interface sentence - * @throws IllegalArgumentException if the separator is Unicode U+0000 - */ - public final ArgumentAcceptingOptionSpec withValuesSeparatedBy( char separator ) { - if ( separator == NIL_VALUE_SEPARATOR ) - throw new IllegalArgumentException( "cannot use U+0000 as separator" ); - - valueSeparator = String.valueOf( separator ); - return this; - } - - /** - *

Specifies a value separator for the argument of the option that this spec represents. This allows a single - * option argument to represent multiple values for the option. For example:

- * - *
-     *   
-     *   parser.accepts( "z" ).withRequiredArg()
-     *       .withValuesSeparatedBy( ":::" );
-     *   OptionSet options = parser.parse( new String[] { "-z", "foo:::bar:::baz", "-z",
-     *       "fizz", "-z", "buzz" } );
-     *   
-     * 
- * - *

Then options.valuesOf( "z" ) would yield the list {@code [foo, bar, baz, fizz, buzz]}.

- * - *

You cannot use Unicode U+0000 in the separator.

- * - * @param separator a string separator - * @return self, so that the caller can add clauses to the fluent interface sentence - * @throws IllegalArgumentException if the separator contains Unicode U+0000 - */ - public final ArgumentAcceptingOptionSpec withValuesSeparatedBy( String separator ) { - if ( separator.indexOf( NIL_VALUE_SEPARATOR ) != -1 ) - throw new IllegalArgumentException( "cannot use U+0000 in separator" ); - - valueSeparator = separator; - return this; - } - - /** - * Specifies a set of default values for the argument of the option that this spec represents. - * - * @param value the first in the set of default argument values for this spec's option - * @param values the (optional) remainder of the set of default argument values for this spec's option - * @return self, so that the caller can add clauses to the fluent interface sentence - * @throws NullPointerException if {@code value}, {@code values}, or any elements of {@code values} are - * {@code null} - */ - @SafeVarargs - public final ArgumentAcceptingOptionSpec defaultsTo( V value, V... values ) { - addDefaultValue( value ); - defaultsTo( values ); - - return this; - } - - /** - * Specifies a set of default values for the argument of the option that this spec represents. - * - * @param values the set of default argument values for this spec's option - * @return self, so that the caller can add clauses to the fluent interface sentence - * @throws NullPointerException if {@code values} or any elements of {@code values} are {@code null} - */ - public ArgumentAcceptingOptionSpec defaultsTo( V[] values ) { - for ( V each : values ) - addDefaultValue( each ); - - return this; - } - - /** - * Marks this option as required. An {@link OptionException} will be thrown when - * {@link OptionParser#parse(java.lang.String...)} is called, if an option is marked as required and not specified - * on the command line. - * - * @return self, so that the caller can add clauses to the fluent interface sentence - */ - public ArgumentAcceptingOptionSpec required() { - optionRequired = true; - return this; - } - - public boolean isRequired() { - return optionRequired; - } - - private void addDefaultValue( V value ) { - requireNonNull( value ); - defaultValues.add( value ); - } - - @Override - final void handleOption( OptionParser parser, ArgumentList arguments, OptionSet detectedOptions, - String detectedArgument ) { - - if ( isNullOrEmpty( detectedArgument ) ) - detectOptionArgument( parser, arguments, detectedOptions ); - else - addArguments( detectedOptions, detectedArgument ); - } - - protected void addArguments( OptionSet detectedOptions, String detectedArgument ) { - StringTokenizer lexer = new StringTokenizer( detectedArgument, valueSeparator ); - if ( !lexer.hasMoreTokens() ) - detectedOptions.addWithArgument( this, detectedArgument ); - else { - while ( lexer.hasMoreTokens() ) - detectedOptions.addWithArgument( this, lexer.nextToken() ); - } - } - - protected abstract void detectOptionArgument( OptionParser parser, ArgumentList arguments, - OptionSet detectedOptions ); - - @Override - protected final V convert( String argument ) { - return convertWith( converter, argument ); - } - - protected boolean canConvertArgument( String argument ) { - StringTokenizer lexer = new StringTokenizer( argument, valueSeparator ); - - try { - while ( lexer.hasMoreTokens() ) - convert( lexer.nextToken() ); - return true; - } catch ( OptionException ignored ) { - return false; - } - } - - protected boolean isArgumentOfNumberType() { - return converter != null && Number.class.isAssignableFrom( converter.valueType() ); - } - - public boolean acceptsArguments() { - return true; - } - - public boolean requiresArgument() { - return argumentRequired; - } - - public String argumentDescription() { - return argumentDescription; - } - - public String argumentTypeIndicator() { - return argumentTypeIndicatorFrom( converter ); - } - - public List defaultValues() { - return unmodifiableList( defaultValues ); - } - - @Override - public boolean equals( Object that ) { - if ( !super.equals( that ) ) - return false; - - ArgumentAcceptingOptionSpec other = (ArgumentAcceptingOptionSpec) that; - return requiresArgument() == other.requiresArgument(); - } - - @Override - public int hashCode() { - return super.hashCode() ^ ( argumentRequired ? 0 : 1 ); - } -} diff --git a/third_party/java/jopt-simple/src/main/java/joptsimple/ArgumentList.java b/third_party/java/jopt-simple/src/main/java/joptsimple/ArgumentList.java deleted file mode 100644 index 744f31aa21..0000000000 --- a/third_party/java/jopt-simple/src/main/java/joptsimple/ArgumentList.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import static joptsimple.ParserRules.*; - -/** - *

Wrapper for an array of command line arguments.

- * - * @author Paul Holser - */ -class ArgumentList { - private final String[] arguments; - private int currentIndex; - - ArgumentList( String... arguments ) { - this.arguments = arguments.clone(); - } - - boolean hasMore() { - return currentIndex < arguments.length; - } - - String next() { - return arguments[ currentIndex++ ]; - } - - String peek() { - return arguments[ currentIndex ]; - } - - void treatNextAsLongOption() { - if ( HYPHEN_CHAR != arguments[ currentIndex ].charAt( 0 ) ) - arguments[ currentIndex ] = DOUBLE_HYPHEN + arguments[ currentIndex ]; - } -} diff --git a/third_party/java/jopt-simple/src/main/java/joptsimple/BuiltinHelpFormatter.java b/third_party/java/jopt-simple/src/main/java/joptsimple/BuiltinHelpFormatter.java deleted file mode 100644 index 51ec603e6f..0000000000 --- a/third_party/java/jopt-simple/src/main/java/joptsimple/BuiltinHelpFormatter.java +++ /dev/null @@ -1,565 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import java.util.*; - -import joptsimple.internal.Messages; -import joptsimple.internal.Rows; -import joptsimple.internal.Strings; - -import static joptsimple.ParserRules.*; -import static joptsimple.internal.Classes.*; -import static joptsimple.internal.Strings.*; - -/** - *

A help formatter that allows configuration of overall row width and column separator width.

- * - *

The formatter produces output in two sections: one for the options, and one for non-option arguments.

- * - *

The options section has two columns: the left column for the options, and the right column for their - * descriptions. The formatter will allow as much space as possible for the descriptions, by minimizing the option - * column's width, no greater than slightly less than half the overall desired width.

- * - *

The non-option arguments section is one column, occupying as much width as it can.

- * - *

Subclasses are free to override bits of this implementation as they see fit. Inspect the code - * carefully to understand the flow of control that this implementation guarantees.

- * - * @author Paul Holser - */ -public class BuiltinHelpFormatter implements HelpFormatter { - private final Rows nonOptionRows; - private final Rows optionRows; - - /** - * Makes a formatter with a pre-configured overall row width and column separator width. - */ - BuiltinHelpFormatter() { - this( 80, 2 ); - } - - /** - * Makes a formatter with a given overall row width and column separator width. - * - * @param desiredOverallWidth how many characters wide to make the overall help display - * @param desiredColumnSeparatorWidth how many characters wide to make the separation between option column and - * description column - */ - public BuiltinHelpFormatter( int desiredOverallWidth, int desiredColumnSeparatorWidth ) { - nonOptionRows = new Rows( desiredOverallWidth * 2, 0 ); - optionRows = new Rows( desiredOverallWidth, desiredColumnSeparatorWidth ); - } - - /** - * {@inheritDoc} - * - *

This implementation:

- *
    - *
  • Sorts the given descriptors by their first elements of {@link OptionDescriptor#options()}
  • - *
  • Passes the resulting sorted set to {@link #addRows(java.util.Collection)}
  • - *
  • Returns the result of {@link #formattedHelpOutput()}
  • - *
- */ - public String format( Map options ) { - optionRows.reset(); - nonOptionRows.reset(); - - Comparator comparator = - new Comparator() { - public int compare( OptionDescriptor first, OptionDescriptor second ) { - return first.options().iterator().next().compareTo( second.options().iterator().next() ); - } - }; - - Set sorted = new TreeSet<>( comparator ); - sorted.addAll( options.values() ); - - addRows( sorted ); - - return formattedHelpOutput(); - } - - /** - * Adds a row of option help output in the left column, with empty space in the right column. - * - * @param single text to put in the left column - */ - protected void addOptionRow( String single ) { - addOptionRow( single, "" ); - } - - /** - * Adds a row of option help output in the left and right columns. - * - * @param left text to put in the left column - * @param right text to put in the right column - */ - protected void addOptionRow( String left, String right ) { - optionRows.add( left, right ); - } - - /** - * Adds a single row of non-option argument help. - * - * @param single single row of non-option argument help text - */ - protected void addNonOptionRow( String single ) { - nonOptionRows.add( single, "" ); - } - - /** - * Resizes the columns of all the rows to be no wider than the widest element in that column. - */ - protected void fitRowsToWidth() { - nonOptionRows.fitToWidth(); - optionRows.fitToWidth(); - } - - /** - * Produces non-option argument help. - * - * @return non-option argument help - */ - protected String nonOptionOutput() { - return nonOptionRows.render(); - } - - /** - * Produces help for options and their descriptions. - * - * @return option help - */ - protected String optionOutput() { - return optionRows.render(); - } - - /** - *

Produces help output for an entire set of options and non-option arguments.

- * - *

This implementation concatenates:

- *
    - *
  • the result of {@link #nonOptionOutput()}
  • - *
  • if there is non-option output, a line separator
  • - *
  • the result of {@link #optionOutput()}
  • - *
- * - * @return help output for entire set of options and non-option arguments - */ - protected String formattedHelpOutput() { - StringBuilder formatted = new StringBuilder(); - String nonOptionDisplay = nonOptionOutput(); - if ( !Strings.isNullOrEmpty( nonOptionDisplay ) ) - formatted.append( nonOptionDisplay ).append( LINE_SEPARATOR ); - formatted.append( optionOutput() ); - - return formatted.toString(); - } - - /** - *

Adds rows of help output for the given options.

- * - *

This implementation:

- *
    - *
  • Calls {@link #addNonOptionsDescription(java.util.Collection)} with the options as the argument
  • - *
  • If there are no options, calls {@link #addOptionRow(String)} with an argument that indicates - * that no options are specified.
  • - *
  • Otherwise, calls {@link #addHeaders(java.util.Collection)} with the options as the argument, - * followed by {@link #addOptions(java.util.Collection)} with the options as the argument.
  • - *
  • Calls {@link #fitRowsToWidth()}.
  • - *
- * - * @param options descriptors for the configured options of a parser - */ - protected void addRows( Collection options ) { - addNonOptionsDescription( options ); - - if ( options.isEmpty() ) - addOptionRow( message( "no.options.specified" ) ); - else { - addHeaders( options ); - addOptions( options ); - } - - fitRowsToWidth(); - } - - /** - *

Adds non-option arguments descriptions to the help output.

- * - *

This implementation:

- *
    - *
  • {@linkplain #findAndRemoveNonOptionsSpec(java.util.Collection) Finds and removes the non-option - * arguments descriptor}
  • - *
  • {@linkplain #shouldShowNonOptionArgumentDisplay(OptionDescriptor) Decides whether there is - * anything to show for non-option arguments}
  • - *
  • If there is, {@linkplain #addNonOptionRow(String) adds a header row} and - * {@linkplain #addNonOptionRow(String) adds a} - * {@linkplain #createNonOptionArgumentsDisplay(OptionDescriptor) non-option arguments description}
  • - *
- * - * @param options descriptors for the configured options of a parser - */ - protected void addNonOptionsDescription( Collection options ) { - OptionDescriptor nonOptions = findAndRemoveNonOptionsSpec( options ); - if ( shouldShowNonOptionArgumentDisplay( nonOptions ) ) { - addNonOptionRow( message( "non.option.arguments.header" ) ); - addNonOptionRow( createNonOptionArgumentsDisplay( nonOptions ) ); - } - } - - /** - *

Decides whether or not to show a non-option arguments help.

- * - *

This implementation responds with {@code true} if the non-option descriptor has a non-{@code null}, - * non-empty value for any of {@link OptionDescriptor#description()}, - * {@link OptionDescriptor#argumentTypeIndicator()}, or {@link OptionDescriptor#argumentDescription()}.

- * - * @param nonOptionDescriptor non-option argument descriptor - * @return {@code true} if non-options argument help should be shown - */ - protected boolean shouldShowNonOptionArgumentDisplay( OptionDescriptor nonOptionDescriptor ) { - return !Strings.isNullOrEmpty( nonOptionDescriptor.description() ) - || !Strings.isNullOrEmpty( nonOptionDescriptor.argumentTypeIndicator() ) - || !Strings.isNullOrEmpty( nonOptionDescriptor.argumentDescription() ); - } - - /** - *

Creates a non-options argument help string.

- * - *

This implementation creates an empty string buffer and calls - * {@link #maybeAppendOptionInfo(StringBuilder, OptionDescriptor)} - * and {@link #maybeAppendNonOptionsDescription(StringBuilder, OptionDescriptor)}, passing them the - * buffer and the non-option arguments descriptor.

- * - * @param nonOptionDescriptor non-option argument descriptor - * @return help string for non-options - */ - protected String createNonOptionArgumentsDisplay( OptionDescriptor nonOptionDescriptor ) { - StringBuilder buffer = new StringBuilder(); - maybeAppendOptionInfo( buffer, nonOptionDescriptor ); - maybeAppendNonOptionsDescription( buffer, nonOptionDescriptor ); - - return buffer.toString(); - } - - /** - *

Appends help for the given non-option arguments descriptor to the given buffer.

- * - *

This implementation appends {@code " -- "} if the buffer has text in it and the non-option arguments - * descriptor has a {@link OptionDescriptor#description()}; followed by the - * {@link OptionDescriptor#description()}.

- * - * @param buffer string buffer - * @param nonOptions non-option arguments descriptor - */ - protected void maybeAppendNonOptionsDescription( StringBuilder buffer, OptionDescriptor nonOptions ) { - buffer.append( buffer.length() > 0 && !Strings.isNullOrEmpty( nonOptions.description() ) ? " -- " : "" ) - .append( nonOptions.description() ); - } - - /** - * Finds the non-option arguments descriptor in the given collection, removes it, and returns it. - * - * @param options descriptors for the configured options of a parser - * @return the non-option arguments descriptor - */ - protected OptionDescriptor findAndRemoveNonOptionsSpec( Collection options ) { - for ( Iterator it = options.iterator(); it.hasNext(); ) { - OptionDescriptor next = it.next(); - if ( next.representsNonOptions() ) { - it.remove(); - return next; - } - } - - throw new AssertionError( "no non-options argument spec" ); - } - - /** - *

Adds help row headers for option help columns.

- * - *

This implementation uses the headers {@code "Option"} and {@code "Description"}. If the options contain - * a "required" option, the {@code "Option"} header looks like {@code "Option (* = required)}. Both headers - * are "underlined" using {@code "-"}.

- * - * @param options descriptors for the configured options of a parser - */ - protected void addHeaders( Collection options ) { - if ( hasRequiredOption( options ) ) { - addOptionRow( message( "option.header.with.required.indicator" ), message( "description.header" ) ); - addOptionRow( message( "option.divider.with.required.indicator" ), message( "description.divider" ) ); - } else { - addOptionRow( message( "option.header" ), message( "description.header" ) ); - addOptionRow( message( "option.divider" ), message( "description.divider" ) ); - } - } - - /** - * Tells whether the given option descriptors contain a "required" option. - * - * @param options descriptors for the configured options of a parser - * @return {@code true} if at least one of the options is "required" - */ - protected final boolean hasRequiredOption( Collection options ) { - for ( OptionDescriptor each : options ) { - if ( each.isRequired() ) - return true; - } - - return false; - } - - /** - *

Adds help rows for the given options.

- * - *

This implementation loops over the given options, and for each, calls {@link #addOptionRow(String, String)} - * using the results of {@link #createOptionDisplay(OptionDescriptor)} and - * {@link #createDescriptionDisplay(OptionDescriptor)}, respectively, as arguments.

- * - * @param options descriptors for the configured options of a parser - */ - protected void addOptions( Collection options ) { - for ( OptionDescriptor each : options ) { - if ( !each.representsNonOptions() ) - addOptionRow( createOptionDisplay( each ), createDescriptionDisplay( each ) ); - } - } - - /** - *

Creates a string for how the given option descriptor is to be represented in help.

- * - *

This implementation gives a string consisting of the concatenation of:

- *
    - *
  • {@code "* "} for "required" options, otherwise {@code ""}
  • - *
  • For each of the {@link OptionDescriptor#options()} of the descriptor, separated by {@code ", "}: - *
      - *
    • {@link #optionLeader(String)} of the option
    • - *
    • the option
    • - *
    - *
  • - *
  • the result of {@link #maybeAppendOptionInfo(StringBuilder, OptionDescriptor)}
  • - *
- * - * @param descriptor a descriptor for a configured option of a parser - * @return help string - */ - protected String createOptionDisplay( OptionDescriptor descriptor ) { - StringBuilder buffer = new StringBuilder( descriptor.isRequired() ? "* " : "" ); - - for ( Iterator i = descriptor.options().iterator(); i.hasNext(); ) { - String option = i.next(); - buffer.append( optionLeader( option ) ); - buffer.append( option ); - - if ( i.hasNext() ) - buffer.append( ", " ); - } - - maybeAppendOptionInfo( buffer, descriptor ); - - return buffer.toString(); - } - - /** - *

Gives a string that represents the given option's "option leader" in help.

- * - *

This implementation answers with {@code "--"} for options of length greater than one; otherwise answers - * with {@code "-"}.

- * - * @param option a string option - * @return an "option leader" string - */ - protected String optionLeader( String option ) { - return option.length() > 1 ? DOUBLE_HYPHEN : HYPHEN; - } - - /** - *

Appends additional info about the given option to the given buffer.

- * - *

This implementation:

- *
    - *
  • calls {@link #extractTypeIndicator(OptionDescriptor)} for the descriptor
  • - *
  • calls {@link joptsimple.OptionDescriptor#argumentDescription()} for the descriptor
  • - *
  • if either of the above is present, calls - * {@link #appendOptionHelp(StringBuilder, String, String, boolean)}
  • - *
- * - * @param buffer string buffer - * @param descriptor a descriptor for a configured option of a parser - */ - protected void maybeAppendOptionInfo( StringBuilder buffer, OptionDescriptor descriptor ) { - String indicator = extractTypeIndicator( descriptor ); - String description = descriptor.argumentDescription(); - if ( descriptor.acceptsArguments() - || !isNullOrEmpty( description ) - || descriptor.representsNonOptions() ) { - - appendOptionHelp( buffer, indicator, description, descriptor.requiresArgument() ); - } - } - - /** - *

Gives an indicator of the type of arguments of the option described by the given descriptor, - * for use in help.

- * - *

This implementation asks for the {@link OptionDescriptor#argumentTypeIndicator()} of the given - * descriptor, and if it is present and not {@code "java.lang.String"}, parses it as a fully qualified - * class name and returns the base name of that class; otherwise returns {@code "String"}.

- * - * @param descriptor a descriptor for a configured option of a parser - * @return type indicator text - */ - protected String extractTypeIndicator( OptionDescriptor descriptor ) { - String indicator = descriptor.argumentTypeIndicator(); - - if ( !isNullOrEmpty( indicator ) && !String.class.getName().equals( indicator ) ) - return shortNameOf( indicator ); - - return "String"; - } - - /** - *

Appends info about an option's argument to the given buffer.

- * - *

This implementation calls {@link #appendTypeIndicator(StringBuilder, String, String, char, char)} with - * the surrounding characters {@code '<'} and {@code '>'} for options with {@code required} arguments, and - * with the surrounding characters {@code '['} and {@code ']'} for options with optional arguments.

- * - * @param buffer string buffer - * @param typeIndicator type indicator - * @param description type description - * @param required indicator of "required"-ness of the argument of the option - */ - protected void appendOptionHelp( StringBuilder buffer, String typeIndicator, String description, - boolean required ) { - if ( required ) - appendTypeIndicator( buffer, typeIndicator, description, '<', '>' ); - else - appendTypeIndicator( buffer, typeIndicator, description, '[', ']' ); - } - - /** - *

Appends a type indicator for an option's argument to the given buffer.

- * - *

This implementation appends, in order:

- *
    - *
  • {@code ' '}
  • - *
  • {@code start}
  • - *
  • the type indicator, if not {@code null}
  • - *
  • if the description is present, then {@code ": "} plus the description if the type indicator is - * present; otherwise the description only
  • - *
  • {@code end}
  • - *
- * - * @param buffer string buffer - * @param typeIndicator type indicator - * @param description type description - * @param start starting character - * @param end ending character - */ - protected void appendTypeIndicator( StringBuilder buffer, String typeIndicator, String description, - char start, char end ) { - buffer.append( ' ' ).append( start ); - if ( typeIndicator != null ) - buffer.append( typeIndicator ); - - if ( !Strings.isNullOrEmpty( description ) ) { - if ( typeIndicator != null ) - buffer.append( ": " ); - - buffer.append( description ); - } - - buffer.append( end ); - } - - /** - *

Gives a string representing a description of the option with the given descriptor.

- * - *

This implementation:

- *
    - *
  • Asks for the descriptor's {@link OptionDescriptor#defaultValues()}
  • - *
  • If they're not present, answers the descriptor's {@link OptionDescriptor#description()}.
  • - *
  • If they are present, concatenates and returns: - *
      - *
    • the descriptor's {@link OptionDescriptor#description()}
    • - *
    • {@code ' '}
    • - *
    • {@code "default: "} plus the result of {@link #createDefaultValuesDisplay(java.util.List)}, - * surrounded by parentheses
    • - *
    - *
  • - *
- * - * @param descriptor a descriptor for a configured option of a parser - * @return display text for the option's description - */ - protected String createDescriptionDisplay( OptionDescriptor descriptor ) { - List defaultValues = descriptor.defaultValues(); - if ( defaultValues.isEmpty() ) - return descriptor.description(); - - String defaultValuesDisplay = createDefaultValuesDisplay( defaultValues ); - return ( descriptor.description() - + ' ' - + surround( message( "default.value.header" ) + ' ' + defaultValuesDisplay, '(', ')' ) - ).trim(); - } - - /** - *

Gives a display string for the default values of an option's argument.

- * - *

This implementation gives the {@link Object#toString()} of the first value if there is only one value, - * otherwise gives the {@link Object#toString()} of the whole list.

- * - * @param defaultValues some default values for a given option's argument - * @return a display string for those default values - */ - protected String createDefaultValuesDisplay( List defaultValues ) { - return defaultValues.size() == 1 ? defaultValues.get( 0 ).toString() : defaultValues.toString(); - } - - /** - *

Looks up and gives a resource bundle message.

- * - *

This implementation looks in the bundle {@code "joptsimple.HelpFormatterMessages"} in the default - * locale, using a key that is the concatenation of this class's fully qualified name, {@code '.'}, - * and the given key suffix, formats the corresponding value using the given arguments, and returns - * the result.

- * - * @param keySuffix suffix to use when looking up the bundle message - * @param args arguments to fill in the message template with - * @return a formatted localized message - */ - protected String message( String keySuffix, Object... args ) { - return Messages.message( - Locale.getDefault(), - "joptsimple.HelpFormatterMessages", - BuiltinHelpFormatter.class, - keySuffix, - args ); - } -} diff --git a/third_party/java/jopt-simple/src/main/java/joptsimple/HelpFormatter.java b/third_party/java/jopt-simple/src/main/java/joptsimple/HelpFormatter.java deleted file mode 100644 index d178d70c09..0000000000 --- a/third_party/java/jopt-simple/src/main/java/joptsimple/HelpFormatter.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import java.util.Map; - -/** - *

Represents objects charged with taking a set of option descriptions and producing some help text from them.

- * - * @author Paul Holser - */ -public interface HelpFormatter { - /** - * Produces help text, given a set of option descriptors. - * - * @param options descriptors for the configured options of a parser - * @return text to be used as help - * @see OptionParser#printHelpOn(java.io.Writer) - * @see OptionParser#formatHelpWith(HelpFormatter) - */ - String format( Map options ); -} diff --git a/third_party/java/jopt-simple/src/main/java/joptsimple/IllegalOptionSpecificationException.java b/third_party/java/jopt-simple/src/main/java/joptsimple/IllegalOptionSpecificationException.java deleted file mode 100644 index 214791544c..0000000000 --- a/third_party/java/jopt-simple/src/main/java/joptsimple/IllegalOptionSpecificationException.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import static java.util.Collections.*; - -/** - * Thrown when the option parser is asked to recognize an option with illegal characters in it. - * - * @author Paul Holser - */ -class IllegalOptionSpecificationException extends OptionException { - private static final long serialVersionUID = -1L; - - IllegalOptionSpecificationException( String option ) { - super( singletonList( option ) ); - } - - @Override - Object[] messageArguments() { - return new Object[] { singleOptionString() }; - } -} diff --git a/third_party/java/jopt-simple/src/main/java/joptsimple/MissingRequiredOptionsException.java b/third_party/java/jopt-simple/src/main/java/joptsimple/MissingRequiredOptionsException.java deleted file mode 100644 index dcb829f342..0000000000 --- a/third_party/java/jopt-simple/src/main/java/joptsimple/MissingRequiredOptionsException.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import java.util.List; - -/** - * Thrown when options marked as required are not specified on the command line. - * - * @author Emils Solmanis - */ -class MissingRequiredOptionsException extends OptionException { - private static final long serialVersionUID = -1L; - - protected MissingRequiredOptionsException( List> missingRequiredOptions ) { - super( missingRequiredOptions ); - } - - @Override - Object[] messageArguments() { - return new Object[] { multipleOptionString() }; - } -} diff --git a/third_party/java/jopt-simple/src/main/java/joptsimple/MultipleArgumentsForOptionException.java b/third_party/java/jopt-simple/src/main/java/joptsimple/MultipleArgumentsForOptionException.java deleted file mode 100644 index 12d1485a39..0000000000 --- a/third_party/java/jopt-simple/src/main/java/joptsimple/MultipleArgumentsForOptionException.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import static java.util.Collections.*; - -/** - * Thrown when asking an {@link OptionSet} for a single argument of an option when many have been specified. - * - * @author Paul Holser - */ -class MultipleArgumentsForOptionException extends OptionException { - private static final long serialVersionUID = -1L; - - MultipleArgumentsForOptionException( OptionSpec options ) { - super( singleton( options ) ); - } - - @Override - Object[] messageArguments() { - return new Object[] { singleOptionString() }; - } -} diff --git a/third_party/java/jopt-simple/src/main/java/joptsimple/NoArgumentOptionSpec.java b/third_party/java/jopt-simple/src/main/java/joptsimple/NoArgumentOptionSpec.java deleted file mode 100644 index 82ac521772..0000000000 --- a/third_party/java/jopt-simple/src/main/java/joptsimple/NoArgumentOptionSpec.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import java.util.List; - -import static java.util.Collections.*; - -/** - * A specification for an option that does not accept arguments. - * - * @author Paul Holser - */ -class NoArgumentOptionSpec extends AbstractOptionSpec { - NoArgumentOptionSpec( String option ) { - this( singletonList( option ), "" ); - } - - NoArgumentOptionSpec( List options, String description ) { - super( options, description ); - } - - @Override - void handleOption( OptionParser parser, ArgumentList arguments, OptionSet detectedOptions, - String detectedArgument ) { - - detectedOptions.add( this ); - } - - public boolean acceptsArguments() { - return false; - } - - public boolean requiresArgument() { - return false; - } - - public boolean isRequired() { - return false; - } - - public String argumentDescription() { - return ""; - } - - public String argumentTypeIndicator() { - return ""; - } - - @Override - protected Void convert( String argument ) { - return null; - } - - public List defaultValues() { - return emptyList(); - } -} diff --git a/third_party/java/jopt-simple/src/main/java/joptsimple/NonOptionArgumentSpec.java b/third_party/java/jopt-simple/src/main/java/joptsimple/NonOptionArgumentSpec.java deleted file mode 100644 index 7343d42c2a..0000000000 --- a/third_party/java/jopt-simple/src/main/java/joptsimple/NonOptionArgumentSpec.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import java.util.List; - -import static java.util.Arrays.*; -import static java.util.Collections.*; -import static joptsimple.internal.Reflection.*; - -/** - *

Specification of a command line's non-option arguments.

- * - *

Instances are returned from {@link OptionParser} methods to allow the formation of parser directives as - * sentences in a "fluent interface" language. For example:

- * - *
- *   
- *   OptionParser parser = new OptionParser();
- *   parser.nonOptions( "files to be processed" ).ofType( File.class );
- *   
- * 
- * - *

If no methods are invoked on an instance of this class, then that instance's option will treat the non-option - * arguments as {@link String}s.

- * - * @param represents the type of the non-option arguments - * @author Paul Holser - */ -public class NonOptionArgumentSpec extends AbstractOptionSpec { - static final String NAME = "[arguments]"; - - private ValueConverter converter; - private String argumentDescription = ""; - - NonOptionArgumentSpec() { - this( "" ); - } - - NonOptionArgumentSpec( String description ) { - super( asList( NAME ), description ); - } - - /** - *

Specifies a type to which the non-option arguments are to be converted.

- * - *

JOpt Simple accepts types that have either:

- * - *
    - *
  1. a public static method called {@code valueOf} which accepts a single argument of type {@link String} - * and whose return type is the same as the class on which the method is declared. The {@code java.lang} - * primitive wrapper classes have such methods.
  2. - * - *
  3. a public constructor which accepts a single argument of type {@link String}.
  4. - *
- * - *

This class converts arguments using those methods in that order; that is, {@code valueOf} would be invoked - * before a one-{@link String}-arg constructor would.

- * - *

Invoking this method will trump any previous calls to this method or to - * {@link #withValuesConvertedBy(ValueConverter)}.

- * - * @param represents the runtime class of the desired option argument type - * @param argumentType desired type of arguments to this spec's option - * @return self, so that the caller can add clauses to the fluent interface sentence - * @throws NullPointerException if the type is {@code null} - * @throws IllegalArgumentException if the type does not have the standard conversion methods - */ - @SuppressWarnings( "unchecked" ) - public NonOptionArgumentSpec ofType( Class argumentType ) { - converter = (ValueConverter) findConverter( argumentType ); - return (NonOptionArgumentSpec) this; - } - - /** - *

Specifies a converter to use to translate non-option arguments into Java objects. This is useful - * when converting to types that do not have the requisite factory method or constructor for - * {@link #ofType(Class)}.

- * - *

Invoking this method will trump any previous calls to this method or to {@link #ofType(Class)}. - * - * @param represents the runtime class of the desired non-option argument type - * @param aConverter the converter to use - * @return self, so that the caller can add clauses to the fluent interface sentence - * @throws NullPointerException if the converter is {@code null} - */ - @SuppressWarnings( "unchecked" ) - public final NonOptionArgumentSpec withValuesConvertedBy( ValueConverter aConverter ) { - if ( aConverter == null ) - throw new NullPointerException( "illegal null converter" ); - - converter = (ValueConverter) aConverter; - return (NonOptionArgumentSpec) this; - } - - /** - *

Specifies a description for the non-option arguments that this spec represents. This description is used - * when generating help information about the parser.

- * - * @param description describes the nature of the argument of this spec's option - * @return self, so that the caller can add clauses to the fluent interface sentence - */ - public NonOptionArgumentSpec describedAs( String description ) { - argumentDescription = description; - return this; - } - - @Override - protected final V convert( String argument ) { - return convertWith( converter, argument ); - } - - @Override - void handleOption( OptionParser parser, ArgumentList arguments, OptionSet detectedOptions, - String detectedArgument ) { - - detectedOptions.addWithArgument( this, detectedArgument ); - } - - public List defaultValues() { - return emptyList(); - } - - public boolean isRequired() { - return false; - } - - public boolean acceptsArguments() { - return false; - } - - public boolean requiresArgument() { - return false; - } - - public String argumentDescription() { - return argumentDescription; - } - - public String argumentTypeIndicator() { - return argumentTypeIndicatorFrom( converter ); - } - - public boolean representsNonOptions() { - return true; - } -} diff --git a/third_party/java/jopt-simple/src/main/java/joptsimple/OptionArgumentConversionException.java b/third_party/java/jopt-simple/src/main/java/joptsimple/OptionArgumentConversionException.java deleted file mode 100644 index 193557d8fa..0000000000 --- a/third_party/java/jopt-simple/src/main/java/joptsimple/OptionArgumentConversionException.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import static java.util.Collections.*; - -/** - * Thrown when a problem occurs converting an argument of an option from {@link String} to another type. - * - * @author Paul Holser - */ -class OptionArgumentConversionException extends OptionException { - private static final long serialVersionUID = -1L; - - private final String argument; - - OptionArgumentConversionException( OptionSpec options, String argument, Throwable cause ) { - super( singleton( options ), cause ); - - this.argument = argument; - } - - @Override - Object[] messageArguments() { - return new Object[] { argument, singleOptionString() }; - } -} diff --git a/third_party/java/jopt-simple/src/main/java/joptsimple/OptionDeclarer.java b/third_party/java/jopt-simple/src/main/java/joptsimple/OptionDeclarer.java deleted file mode 100644 index 7d54653443..0000000000 --- a/third_party/java/jopt-simple/src/main/java/joptsimple/OptionDeclarer.java +++ /dev/null @@ -1,116 +0,0 @@ -package joptsimple; - -import java.util.List; - -/** - * Trains the option parser. This interface aids integration that disposes declaration of options but not actual - * command-line parsing. - * - * Typical use is for another class to implement {@code OptionDeclarer} as a facade, forwarding calls to an - * {@code OptionParser} instance. - * - * Note that although this is an interface, the returned values of calls are concrete jopt-simple classes. - * - * @author Paul Holser - * @see OptionParser - * @since 4.6 - */ -public interface OptionDeclarer { - /** - * Tells the parser to recognize the given option. - * - *

This method returns an instance of {@link OptionSpecBuilder} to allow the formation of parser directives - * as sentences in a fluent interface language. For example:

- * - *

-     *   OptionDeclarer parser = new OptionParser();
-     *   parser.accepts( "c" ).withRequiredArg().ofType( Integer.class );
-     * 
- * - *

If no methods are invoked on the returned {@link OptionSpecBuilder}, then the parser treats the option as - * accepting no argument.

- * - * @param option the option to recognize - * @return an object that can be used to flesh out more detail about the option - * @throws OptionException if the option contains illegal characters - * @throws NullPointerException if the option is {@code null} - */ - OptionSpecBuilder accepts( String option ); - - /** - * Tells the parser to recognize the given option. - * - * @see #accepts(String) - * @param option the option to recognize - * @param description a string that describes the purpose of the option. This is used when generating help - * information about the parser. - * @return an object that can be used to flesh out more detail about the option - * @throws OptionException if the option contains illegal characters - * @throws NullPointerException if the option is {@code null} - */ - OptionSpecBuilder accepts( String option, String description ); - - /** - * Tells the parser to recognize the given options, and treat them as synonymous. - * - * @see #accepts(String) - * @param options the options to recognize and treat as synonymous - * @return an object that can be used to flesh out more detail about the options - * @throws OptionException if any of the options contain illegal characters - * @throws NullPointerException if the option list or any of its elements are {@code null} - */ - OptionSpecBuilder acceptsAll( List options ); - - /** - * Tells the parser to recognize the given options, and treat them as synonymous. - * - * @see #acceptsAll(List) - * @param options the options to recognize and treat as synonymous - * @param description a string that describes the purpose of the option. This is used when generating help - * information about the parser. - * @return an object that can be used to flesh out more detail about the options - * @throws OptionException if any of the options contain illegal characters - * @throws NullPointerException if the option list or any of its elements are {@code null} - * @throws IllegalArgumentException if the option list is empty - */ - OptionSpecBuilder acceptsAll( List options, String description ); - - /** - * Gives an object that represents an access point for non-option arguments on a command line. - * - * @return an object that can be used to flesh out more detail about the non-option arguments - */ - NonOptionArgumentSpec nonOptions(); - - /** - * Gives an object that represents an access point for non-option arguments on a command line. - * - * @see #nonOptions() - * @param description a string that describes the purpose of the non-option arguments. This is used when generating - * help information about the parser. - * @return an object that can be used to flesh out more detail about the non-option arguments - */ - NonOptionArgumentSpec nonOptions( String description ); - - /** - * Tells the parser whether or not to behave "POSIX-ly correct"-ly. - * - * @param setting {@code true} if the parser should behave "POSIX-ly correct"-ly - */ - void posixlyCorrect( boolean setting ); - - /** - *

Tells the parser to treat unrecognized options as non-option arguments.

- * - *

If not called, then the parser raises an {@link OptionException} when it encounters an unrecognized - * option.

- */ - void allowsUnrecognizedOptions(); - - /** - * Tells the parser either to recognize or ignore {@code -W}-style long options. - * - * @param recognize {@code true} if the parser is to recognize the special style of long options - */ - void recognizeAlternativeLongOptions( boolean recognize ); -} diff --git a/third_party/java/jopt-simple/src/main/java/joptsimple/OptionDescriptor.java b/third_party/java/jopt-simple/src/main/java/joptsimple/OptionDescriptor.java deleted file mode 100644 index f77c775223..0000000000 --- a/third_party/java/jopt-simple/src/main/java/joptsimple/OptionDescriptor.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import java.util.List; - -/** - * Describes options that an option parser recognizes, in ways that might be useful to {@linkplain HelpFormatter - * help screens}. - * - * @author Paul Holser - */ -public interface OptionDescriptor { - /** - * A set of options that are mutually synonymous. - * - * @return synonymous options - */ - List options(); - - /** - * Description of this option's purpose. - * - * @return a description for the option - */ - String description(); - - /** - * What values will the option take if none are specified on the command line? - * - * @return any default values for the option - */ - List defaultValues(); - - /** - * Is this option {@linkplain ArgumentAcceptingOptionSpec#required() required} on a command line? - * - * @return whether the option is required - */ - boolean isRequired(); - - /** - * Does this option {@linkplain ArgumentAcceptingOptionSpec accept arguments}? - * - * @return whether the option accepts arguments - */ - boolean acceptsArguments(); - - /** - * Does this option {@linkplain OptionSpecBuilder#withRequiredArg() require an argument}? - * - * @return whether the option requires an argument - */ - boolean requiresArgument(); - - /** - * Gives a short {@linkplain ArgumentAcceptingOptionSpec#describedAs(String) description} of the option's argument. - * - * @return a description for the option's argument - */ - String argumentDescription(); - - /** - * Gives an indication of the {@linkplain ArgumentAcceptingOptionSpec#ofType(Class) expected type} of the option's - * argument. - * - * @return a description for the option's argument type - */ - String argumentTypeIndicator(); - - /** - * Tells whether this object represents the non-option arguments of a command line. - * - * @return {@code true} if this represents non-option arguments - */ - boolean representsNonOptions(); -} diff --git a/third_party/java/jopt-simple/src/main/java/joptsimple/OptionException.java b/third_party/java/jopt-simple/src/main/java/joptsimple/OptionException.java deleted file mode 100644 index 88e7e43f2e..0000000000 --- a/third_party/java/jopt-simple/src/main/java/joptsimple/OptionException.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Locale; -import java.util.Set; - -import joptsimple.internal.Strings; - -import static java.util.Collections.*; -import static joptsimple.internal.Messages.*; - -/** - * Thrown when a problem occurs during option parsing. - * - * @author Paul Holser - */ -public abstract class OptionException extends RuntimeException { - private static final long serialVersionUID = -1L; - - private final List options = new ArrayList<>(); - - protected OptionException( List options ) { - this.options.addAll( options ); - } - - protected OptionException( Collection> options ) { - this.options.addAll( specsToStrings( options ) ); - } - - protected OptionException( Collection> options, Throwable cause ) { - super( cause ); - this.options.addAll( specsToStrings( options ) ); - } - - private List specsToStrings( Collection> options ) { - List strings = new ArrayList<>(); - for ( OptionSpec each : options ) - strings.add( specToString( each ) ); - return strings; - } - - private String specToString( OptionSpec option ) { - return Strings.join( new ArrayList<>( option.options() ), "/" ); - } - - /** - * Gives the option being considered when the exception was created. - * - * @return the option being considered when the exception was created - */ - public List options() { - return unmodifiableList( options ); - } - - protected final String singleOptionString() { - return singleOptionString( options.get( 0 ) ); - } - - protected final String singleOptionString( String option ) { - return option; - } - - protected final String multipleOptionString() { - StringBuilder buffer = new StringBuilder( "[" ); - - Set asSet = new LinkedHashSet( options ); - for ( Iterator iter = asSet.iterator(); iter.hasNext(); ) { - buffer.append( singleOptionString(iter.next()) ); - if ( iter.hasNext() ) - buffer.append( ", " ); - } - - buffer.append( ']' ); - - return buffer.toString(); - } - - static OptionException unrecognizedOption( String option ) { - return new UnrecognizedOptionException( option ); - } - - @Override - public final String getMessage() { - return localizedMessage( Locale.getDefault() ); - } - - final String localizedMessage( Locale locale ) { - return formattedMessage( locale ); - } - - private String formattedMessage( Locale locale ) { - return message( locale, "joptsimple.ExceptionMessages", getClass(), "message", messageArguments() ); - } - - abstract Object[] messageArguments(); -} diff --git a/third_party/java/jopt-simple/src/main/java/joptsimple/OptionMissingRequiredArgumentException.java b/third_party/java/jopt-simple/src/main/java/joptsimple/OptionMissingRequiredArgumentException.java deleted file mode 100644 index 9c69f12369..0000000000 --- a/third_party/java/jopt-simple/src/main/java/joptsimple/OptionMissingRequiredArgumentException.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import static java.util.Arrays.*; - -/** - * Thrown when the option parser discovers options that require an argument, but are missing an argument. - * - * @author Paul Holser - */ -class OptionMissingRequiredArgumentException extends OptionException { - private static final long serialVersionUID = -1L; - - OptionMissingRequiredArgumentException( OptionSpec option ) { - super( asList( option ) ); - } - - @Override - Object[] messageArguments() { - return new Object[] { singleOptionString() }; - } -} diff --git a/third_party/java/jopt-simple/src/main/java/joptsimple/OptionParser.java b/third_party/java/jopt-simple/src/main/java/joptsimple/OptionParser.java deleted file mode 100644 index d141f623c0..0000000000 --- a/third_party/java/jopt-simple/src/main/java/joptsimple/OptionParser.java +++ /dev/null @@ -1,647 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import java.io.IOException; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.io.Writer; -import java.util.*; - -import joptsimple.internal.AbbreviationMap; -import joptsimple.internal.SimpleOptionNameMap; -import joptsimple.internal.OptionNameMap; -import joptsimple.util.KeyValuePair; - -import static java.util.Collections.*; -import static joptsimple.OptionException.*; -import static joptsimple.OptionParserState.*; -import static joptsimple.ParserRules.*; - -/** - *

Parses command line arguments, using a syntax that attempts to take from the best of POSIX {@code getopt()} - * and GNU {@code getopt_long()}.

- * - *

This parser supports short options and long options.

- * - *
    - *
  • Short options begin with a single hyphen ("{@code -}") followed by a single letter or digit, - * or question mark ("{@code ?}"), or dot ("{@code .}"), or underscore ("{@code _}").
  • - * - *
  • Short options can accept single arguments. The argument can be made required or optional. The option's - * argument can occur: - *
      - *
    • in the slot after the option, as in {@code -d /tmp}
    • - *
    • right up against the option, as in {@code -d/tmp}
    • - *
    • right up against the option separated by an equals sign ({@code "="}), as in {@code -d=/tmp}
    • - *
    - * To specify n arguments for an option, specify the option n times, once for each argument, - * as in {@code -d /tmp -d /var -d /opt}; or, when using the - * {@linkplain ArgumentAcceptingOptionSpec#withValuesSeparatedBy(char) "separated values"} clause of the "fluent - * interface" (see below), give multiple values separated by a given character as a single argument to the - * option.
  • - * - *
  • Short options can be clustered, so that {@code -abc} is treated as {@code -a -b -c}. If a short option - * in the cluster can accept an argument, the remaining characters are interpreted as the argument for that - * option.
  • - * - *
  • An argument consisting only of two hyphens ({@code "--"}) signals that the remaining arguments are to be - * treated as non-options.
  • - * - *
  • An argument consisting only of a single hyphen is considered a non-option argument (though it can be an - * argument of an option). Many Unix programs treat single hyphens as stand-ins for the standard input or standard - * output streams.
  • - * - *
  • Long options begin with two hyphens ({@code "--"}), followed by multiple letters, digits, - * hyphens, question marks, or dots. A hyphen cannot be the first character of a long option specification when - * configuring the parser.
  • - * - *
  • You can abbreviate long options, so long as the abbreviation is unique. Suppress this behavior if - * you wish using {@linkplain OptionParser#OptionParser(boolean) this constructor}.
  • - * - *
  • Long options can accept single arguments. The argument can be made required or optional. The option's - * argument can occur: - *
      - *
    • in the slot after the option, as in {@code --directory /tmp}
    • - *
    • right up against the option separated by an equals sign ({@code "="}), as in - * {@code --directory=/tmp} - *
    - * Specify multiple arguments for a long option in the same manner as for short options (see above).
  • - * - *
  • You can use a single hyphen ({@code "-"}) instead of a double hyphen ({@code "--"}) for a long - * option.
  • - * - *
  • The option {@code -W} is reserved. If you tell the parser to {@linkplain - * #recognizeAlternativeLongOptions(boolean) recognize alternative long options}, then it will treat, for example, - * {@code -W foo=bar} as the long option {@code foo} with argument {@code bar}, as though you had written - * {@code --foo=bar}.
  • - * - *
  • You can specify {@code -W} as a valid short option, or use it as an abbreviation for a long option, but - * {@linkplain #recognizeAlternativeLongOptions(boolean) recognizing alternative long options} will always supersede - * this behavior.
  • - * - *
  • You can specify a given short or long option multiple times on a single command line. The parser collects - * any arguments specified for those options as a list.
  • - * - *
  • If the parser detects an option whose argument is optional, and the next argument "looks like" an option, - * that argument is not treated as the argument to the option, but as a potentially valid option. If, on the other - * hand, the optional argument is typed as a derivative of {@link Number}, then that argument is treated as the - * negative number argument of the option, even if the parser recognizes the corresponding numeric option. - * For example: - *
    
    - *     OptionParser parser = new OptionParser();
    - *     parser.accepts( "a" ).withOptionalArg().ofType( Integer.class );
    - *     parser.accepts( "2" );
    - *     OptionSet options = parser.parse( "-a", "-2" );
    - *   
    - * In this case, the option set contains {@code "a"} with argument {@code -2}, not both {@code "a"} and - * {@code "2"}. Swapping the elements in the args array gives the latter.
  • - *
- * - *

There are two ways to tell the parser what options to recognize:

- * - *
    - *
  1. A "fluent interface"-style API for specifying options, available since version 2. Sentences in this fluent - * interface language begin with a call to {@link #accepts(String) accepts} or {@link #acceptsAll(List) - * acceptsAll} methods; calls on the ensuing chain of objects describe whether the options can take an argument, - * whether the argument is required or optional, to what type arguments of the options should be converted if any, - * etc. Since version 3, these calls return an instance of {@link OptionSpec}, which can subsequently be used to - * retrieve the arguments of the associated option in a type-safe manner.
  2. - * - *
  3. Since version 1, a more concise way of specifying short options has been to use the special {@linkplain - * #OptionParser(String) constructor}. Arguments of options specified in this manner will be of type {@link String}. - * Here are the rules for the format of the specification strings this constructor accepts: - * - *
      - *
    • Any letter or digit is treated as an option character.
    • - * - *
    • An option character can be immediately followed by an asterisk ({@code *)} to indicate that - * the option is a "help" option.
    • - * - *
    • If an option character (with possible trailing asterisk) is followed by a single colon ({@code ":"}), - * then the option requires an argument.
    • - * - *
    • If an option character (with possible trailing asterisk) is followed by two colons ({@code "::"}), - * then the option accepts an optional argument.
    • - * - *
    • Otherwise, the option character accepts no argument.
    • - * - *
    • If the option specification string begins with a plus sign ({@code "+" }), the parser will behave - * "POSIX-ly correct".
    • - * - *
    • If the option specification string contains the sequence {@code "W;"} (capital W followed by a - * semicolon), the parser will recognize the alternative form of long options.
    • - *
    - *
  4. - *
- * - *

Each of the options in a list of options given to {@link #acceptsAll(List) acceptsAll} is treated as a - * synonym of the others. For example:

- *
- *     
- *     OptionParser parser = new OptionParser();
- *     parser.acceptsAll( asList( "w", "interactive", "confirmation" ) );
- *     OptionSet options = parser.parse( "-w" );
- *     
- *   
- *

In this case, options.{@link OptionSet#has(String) has} would answer {@code true} when given arguments - * {@code "w"}, {@code "interactive"}, and {@code "confirmation"}. The {@link OptionSet} would give the same - * responses to these arguments for its other methods as well.

- * - *

By default, as with GNU {@code getopt()}, the parser allows intermixing of options and non-options. If, however, - * the parser has been created to be "POSIX-ly correct", then the first argument that does not look lexically like an - * option, and is not a required argument of a preceding option, signals the end of options. You can still bind - * optional arguments to their options using the abutting (for short options) or {@code =} syntax.

- * - *

Unlike GNU {@code getopt()}, this parser does not honor the environment variable {@code POSIXLY_CORRECT}. - * "POSIX-ly correct" parsers are configured by either:

- * - *
    - *
  1. using the method {@link #posixlyCorrect(boolean)}, or
  2. - * - *
  3. using the {@linkplain #OptionParser(String) constructor} with an argument whose first character is a plus sign - * ({@code "+"})
  4. - *
- * - * @author Paul Holser - * @see The GNU C Library - */ -public class OptionParser implements OptionDeclarer { - private final OptionNameMap> recognizedOptions; - private final ArrayList> trainingOrder; - private final Map, Set>> requiredIf; - private final Map, Set>> requiredUnless; - private final Map, Set>> availableIf; - private final Map, Set>> availableUnless; - - private OptionParserState state; - private boolean posixlyCorrect; - private boolean allowsUnrecognizedOptions; - private HelpFormatter helpFormatter = new BuiltinHelpFormatter(); - - /** - * Creates an option parser that initially recognizes no options, and does not exhibit "POSIX-ly correct" - * behavior. - */ - public OptionParser() { - this(true); - } - - /** - * Creates an option parser that initially recognizes no options, and does not exhibit "POSIX-ly correct" - * behavior. - * - * @param allowAbbreviations whether unambiguous abbreviations of long options should be recognized - * by the parser - */ - public OptionParser( boolean allowAbbreviations ) { - trainingOrder = new ArrayList<>(); - requiredIf = new HashMap<>(); - requiredUnless = new HashMap<>(); - availableIf = new HashMap<>(); - availableUnless = new HashMap<>(); - state = moreOptions( false ); - - recognizedOptions = allowAbbreviations - ? new AbbreviationMap>() - : new SimpleOptionNameMap>(); - - recognize( new NonOptionArgumentSpec() ); - } - - /** - * Creates an option parser and configures it to recognize the short options specified in the given string. - * - * Arguments of options specified this way will be of type {@link String}. - * - * @param optionSpecification an option specification - * @throws NullPointerException if {@code optionSpecification} is {@code null} - * @throws OptionException if the option specification contains illegal characters or otherwise cannot be - * recognized - */ - public OptionParser( String optionSpecification ) { - this(); - - new OptionSpecTokenizer( optionSpecification ).configure( this ); - } - - public OptionSpecBuilder accepts( String option ) { - return acceptsAll( singletonList( option ) ); - } - - public OptionSpecBuilder accepts( String option, String description ) { - return acceptsAll( singletonList( option ), description ); - } - - public OptionSpecBuilder acceptsAll( List options ) { - return acceptsAll( options, "" ); - } - - public OptionSpecBuilder acceptsAll( List options, String description ) { - if ( options.isEmpty() ) - throw new IllegalArgumentException( "need at least one option" ); - - ensureLegalOptions( options ); - - return new OptionSpecBuilder( this, options, description ); - } - - public NonOptionArgumentSpec nonOptions() { - NonOptionArgumentSpec spec = new NonOptionArgumentSpec<>(); - - recognize( spec ); - - return spec; - } - - public NonOptionArgumentSpec nonOptions( String description ) { - NonOptionArgumentSpec spec = new NonOptionArgumentSpec<>( description ); - - recognize( spec ); - - return spec; - } - - public void posixlyCorrect( boolean setting ) { - posixlyCorrect = setting; - state = moreOptions( setting ); - } - - boolean posixlyCorrect() { - return posixlyCorrect; - } - - public void allowsUnrecognizedOptions() { - allowsUnrecognizedOptions = true; - } - - boolean doesAllowsUnrecognizedOptions() { - return allowsUnrecognizedOptions; - } - - public void recognizeAlternativeLongOptions( boolean recognize ) { - if ( recognize ) - recognize( new AlternativeLongOptionSpec() ); - else - recognizedOptions.remove( String.valueOf( RESERVED_FOR_EXTENSIONS ) ); - } - - void recognize( AbstractOptionSpec spec ) { - recognizedOptions.putAll( spec.options(), spec ); - trainingOrder.add( spec ); - } - - /** - * Writes information about the options this parser recognizes to the given output sink. - * - * The output sink is flushed, but not closed. - * - * @param sink the sink to write information to - * @throws IOException if there is a problem writing to the sink - * @throws NullPointerException if {@code sink} is {@code null} - * @see #printHelpOn(Writer) - */ - public void printHelpOn( OutputStream sink ) throws IOException { - printHelpOn( new OutputStreamWriter( sink ) ); - } - - /** - * Writes information about the options this parser recognizes to the given output sink. - * - * The output sink is flushed, but not closed. - * - * @param sink the sink to write information to - * @throws IOException if there is a problem writing to the sink - * @throws NullPointerException if {@code sink} is {@code null} - * @see #printHelpOn(OutputStream) - */ - public void printHelpOn( Writer sink ) throws IOException { - sink.write( helpFormatter.format( _recognizedOptions() ) ); - sink.flush(); - } - - /** - * Tells the parser to use the given formatter when asked to {@linkplain #printHelpOn(java.io.Writer) print help}. - * - * @param formatter the formatter to use for printing help - * @throws NullPointerException if the formatter is {@code null} - */ - public void formatHelpWith( HelpFormatter formatter ) { - if ( formatter == null ) - throw new NullPointerException(); - - helpFormatter = formatter; - } - - /** - * Retrieves all options-spec pairings which have been configured for the parser in the same order as declared - * during training. Option flags for specs are alphabetized by {@link OptionSpec#options()}; only the order of the - * specs is preserved. - * - * (Note: prior to 4.7 the order was alphabetical across all options regardless of spec.) - * - * @return a map containing all the configured options and their corresponding {@link OptionSpec} - * @since 4.6 - */ - public Map> recognizedOptions() { - return new LinkedHashMap>( _recognizedOptions() ); - } - - private Map> _recognizedOptions() { - Map> options = new LinkedHashMap<>(); - for ( AbstractOptionSpec spec : trainingOrder ) { - for ( String option : spec.options() ) - options.put( option, spec ); - } - return options; - } - - /** - * Parses the given command line arguments according to the option specifications given to the parser. - * - * @param arguments arguments to parse - * @return an {@link OptionSet} describing the parsed options, their arguments, and any non-option arguments found - * @throws OptionException if problems are detected while parsing - * @throws NullPointerException if the argument list is {@code null} - */ - public OptionSet parse( String... arguments ) { - ArgumentList argumentList = new ArgumentList( arguments ); - OptionSet detected = new OptionSet( recognizedOptions.toJavaUtilMap() ); - detected.add( recognizedOptions.get( NonOptionArgumentSpec.NAME ) ); - - while ( argumentList.hasMore() ) - state.handleArgument( this, argumentList, detected ); - - reset(); - - ensureRequiredOptions( detected ); - ensureAllowedOptions( detected ); - - return detected; - } - - /** - * Mandates mutual exclusiveness for the options built by the specified builders. - * - * @param specs descriptors for options that should be mutually exclusive on a command line. - * @throws NullPointerException if {@code specs} is {@code null} - */ - public void mutuallyExclusive( OptionSpecBuilder... specs ) { - for ( int i = 0; i < specs.length; i++ ) { - for ( int j = 0; j < specs.length; j++ ) { - if ( i != j ) - specs[i].availableUnless( specs[j] ); - } - } - } - - private void ensureRequiredOptions( OptionSet options ) { - List> missingRequiredOptions = missingRequiredOptions(options); - boolean helpOptionPresent = isHelpOptionPresent( options ); - - if ( !missingRequiredOptions.isEmpty() && !helpOptionPresent ) - throw new MissingRequiredOptionsException( missingRequiredOptions ); - } - - private void ensureAllowedOptions( OptionSet options ) { - List> forbiddenOptions = unavailableOptions( options ); - boolean helpOptionPresent = isHelpOptionPresent( options ); - - if ( !forbiddenOptions.isEmpty() && !helpOptionPresent ) - throw new UnavailableOptionException( forbiddenOptions ); - } - - private List> missingRequiredOptions( OptionSet options ) { - List> missingRequiredOptions = new ArrayList<>(); - - for ( AbstractOptionSpec each : recognizedOptions.toJavaUtilMap().values() ) { - if ( each.isRequired() && !options.has( each ) ) - missingRequiredOptions.add(each); - } - - for ( Map.Entry, Set>> each : requiredIf.entrySet() ) { - AbstractOptionSpec required = specFor( each.getKey().iterator().next() ); - - if ( optionsHasAnyOf( options, each.getValue() ) && !options.has( required ) ) - missingRequiredOptions.add( required ); - } - - for ( Map.Entry, Set>> each : requiredUnless.entrySet() ) { - AbstractOptionSpec required = specFor(each.getKey().iterator().next()); - - if ( !optionsHasAnyOf( options, each.getValue() ) && !options.has( required ) ) - missingRequiredOptions.add( required ); - } - - return missingRequiredOptions; - } - - private List> unavailableOptions(OptionSet options) { - List> unavailableOptions = new ArrayList<>(); - - for ( Map.Entry, Set>> eachEntry : availableIf.entrySet() ) { - AbstractOptionSpec forbidden = specFor( eachEntry.getKey().iterator().next() ); - - if ( !optionsHasAnyOf( options, eachEntry.getValue() ) && options.has( forbidden ) ) { - unavailableOptions.add(forbidden); - } - } - - for ( Map.Entry, Set>> eachEntry : availableUnless.entrySet() ) { - AbstractOptionSpec forbidden = specFor( eachEntry.getKey().iterator().next() ); - - if ( optionsHasAnyOf( options, eachEntry.getValue() ) && options.has( forbidden ) ) { - unavailableOptions.add(forbidden); - } - } - - return unavailableOptions; - } - - private boolean optionsHasAnyOf( OptionSet options, Collection> specs ) { - for ( OptionSpec each : specs ) { - if ( options.has( each ) ) - return true; - } - - return false; - } - - private boolean isHelpOptionPresent( OptionSet options ) { - boolean helpOptionPresent = false; - - for ( AbstractOptionSpec each : recognizedOptions.toJavaUtilMap().values() ) { - if ( each.isForHelp() && options.has( each ) ) { - helpOptionPresent = true; - break; - } - } - - return helpOptionPresent; - } - - void handleLongOptionToken( String candidate, ArgumentList arguments, OptionSet detected ) { - KeyValuePair optionAndArgument = parseLongOptionWithArgument( candidate ); - - if ( !isRecognized( optionAndArgument.key ) ) - throw unrecognizedOption( optionAndArgument.key ); - - AbstractOptionSpec optionSpec = specFor( optionAndArgument.key ); - optionSpec.handleOption( this, arguments, detected, optionAndArgument.value ); - } - - void handleShortOptionToken( String candidate, ArgumentList arguments, OptionSet detected ) { - KeyValuePair optionAndArgument = parseShortOptionWithArgument( candidate ); - - if ( isRecognized( optionAndArgument.key ) ) { - specFor( optionAndArgument.key ).handleOption( this, arguments, detected, optionAndArgument.value ); - } - else - handleShortOptionCluster( candidate, arguments, detected ); - } - - private void handleShortOptionCluster( String candidate, ArgumentList arguments, OptionSet detected ) { - char[] options = extractShortOptionsFrom( candidate ); - validateOptionCharacters( options ); - - for ( int i = 0; i < options.length; i++ ) { - AbstractOptionSpec optionSpec = specFor( options[ i ] ); - - if ( optionSpec.acceptsArguments() && options.length > i + 1 ) { - String detectedArgument = String.valueOf( options, i + 1, options.length - 1 - i ); - optionSpec.handleOption( this, arguments, detected, detectedArgument ); - break; - } - - optionSpec.handleOption( this, arguments, detected, null ); - } - } - - void handleNonOptionArgument( String candidate, ArgumentList arguments, OptionSet detectedOptions ) { - specFor( NonOptionArgumentSpec.NAME ).handleOption( this, arguments, detectedOptions, candidate ); - } - - void noMoreOptions() { - state = OptionParserState.noMoreOptions(); - } - - boolean looksLikeAnOption( String argument ) { - return isShortOptionToken( argument ) || isLongOptionToken( argument ); - } - - boolean isRecognized( String option ) { - return recognizedOptions.contains( option ); - } - - void requiredIf( List precedentSynonyms, String required ) { - requiredIf( precedentSynonyms, specFor( required ) ); - } - - void requiredIf( List precedentSynonyms, OptionSpec required ) { - putDependentOption( precedentSynonyms, required, requiredIf ); - } - - void requiredUnless( List precedentSynonyms, String required ) { - requiredUnless( precedentSynonyms, specFor( required ) ); - } - - void requiredUnless( List precedentSynonyms, OptionSpec required ) { - putDependentOption( precedentSynonyms, required, requiredUnless ); - } - - void availableIf( List precedentSynonyms, String available ) { - availableIf( precedentSynonyms, specFor( available ) ); - } - - void availableIf( List precedentSynonyms, OptionSpec available) { - putDependentOption( precedentSynonyms, available, availableIf ); - } - - void availableUnless( List precedentSynonyms, String available ) { - availableUnless( precedentSynonyms, specFor( available ) ); - } - - void availableUnless( List precedentSynonyms, OptionSpec available ) { - putDependentOption( precedentSynonyms, available, availableUnless ); - } - - private void putDependentOption( List precedentSynonyms, OptionSpec required, - Map, Set>> target ) { - - for ( String each : precedentSynonyms ) { - AbstractOptionSpec spec = specFor( each ); - if ( spec == null ) - throw new UnconfiguredOptionException( precedentSynonyms ); - } - - Set> associated = target.get( precedentSynonyms ); - if ( associated == null ) { - associated = new HashSet<>(); - target.put( precedentSynonyms, associated ); - } - - associated.add( required ); - } - - private AbstractOptionSpec specFor( char option ) { - return specFor( String.valueOf( option ) ); - } - - private AbstractOptionSpec specFor( String option ) { - return recognizedOptions.get( option ); - } - - private void reset() { - state = moreOptions( posixlyCorrect ); - } - - private static char[] extractShortOptionsFrom( String argument ) { - char[] options = new char[ argument.length() - 1 ]; - argument.getChars( 1, argument.length(), options, 0 ); - - return options; - } - - private void validateOptionCharacters( char[] options ) { - for ( char each : options ) { - String option = String.valueOf( each ); - - if ( !isRecognized( option ) ) - throw unrecognizedOption( option ); - - if ( specFor( option ).acceptsArguments() ) - return; - } - } - - private static KeyValuePair parseLongOptionWithArgument( String argument ) { - return KeyValuePair.valueOf( argument.substring( 2 ) ); - } - - private static KeyValuePair parseShortOptionWithArgument( String argument ) { - return KeyValuePair.valueOf( argument.substring( 1 ) ); - } -} diff --git a/third_party/java/jopt-simple/src/main/java/joptsimple/OptionParserState.java b/third_party/java/jopt-simple/src/main/java/joptsimple/OptionParserState.java deleted file mode 100644 index fe1000c263..0000000000 --- a/third_party/java/jopt-simple/src/main/java/joptsimple/OptionParserState.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import static joptsimple.ParserRules.*; - -/** - * Abstraction of parser state; mostly serves to model how a parser behaves depending on whether end-of-options - * has been detected. - * - * @author Paul Holser - */ -abstract class OptionParserState { - static OptionParserState noMoreOptions() { - return new OptionParserState() { - @Override - protected void handleArgument( OptionParser parser, ArgumentList arguments, OptionSet detectedOptions ) { - parser.handleNonOptionArgument( arguments.next(), arguments, detectedOptions ); - } - }; - } - - static OptionParserState moreOptions( final boolean posixlyCorrect ) { - return new OptionParserState() { - @Override - protected void handleArgument( OptionParser parser, ArgumentList arguments, OptionSet detectedOptions ) { - String candidate = arguments.next(); - try { - if ( isOptionTerminator( candidate ) ) { - parser.noMoreOptions(); - return; - } else if ( isLongOptionToken( candidate ) ) { - parser.handleLongOptionToken( candidate, arguments, detectedOptions ); - return; - } else if ( isShortOptionToken( candidate ) ) { - parser.handleShortOptionToken( candidate, arguments, detectedOptions ); - return; - } - } catch ( UnrecognizedOptionException e ) { - if ( !parser.doesAllowsUnrecognizedOptions() ) - throw e; - } - - if ( posixlyCorrect ) - parser.noMoreOptions(); - - parser.handleNonOptionArgument( candidate, arguments, detectedOptions ); - } - }; - } - - protected abstract void handleArgument( OptionParser parser, ArgumentList arguments, OptionSet detectedOptions ); -} diff --git a/third_party/java/jopt-simple/src/main/java/joptsimple/OptionSet.java b/third_party/java/jopt-simple/src/main/java/joptsimple/OptionSet.java deleted file mode 100644 index e67363fd2e..0000000000 --- a/third_party/java/jopt-simple/src/main/java/joptsimple/OptionSet.java +++ /dev/null @@ -1,325 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.IdentityHashMap; -import java.util.List; -import java.util.Map; - -import static java.util.Collections.*; -import static java.util.Objects.*; - -/** - * Representation of a group of detected command line options, their arguments, and non-option arguments. - * - * @author Paul Holser - */ -public class OptionSet { - private final List> detectedSpecs; - private final Map> detectedOptions; - private final Map, List> optionsToArguments; - private final Map> recognizedSpecs; - private final Map> defaultValues; - - /* - * Package-private because clients don't create these. - */ - OptionSet( Map> recognizedSpecs ) { - detectedSpecs = new ArrayList<>(); - detectedOptions = new HashMap<>(); - optionsToArguments = new IdentityHashMap<>(); - defaultValues = defaultValues( recognizedSpecs ); - this.recognizedSpecs = recognizedSpecs; - } - - /** - * Tells whether any options were detected. - * - * @return {@code true} if any options were detected - */ - public boolean hasOptions() { - return !( detectedOptions.size() == 1 && detectedOptions.values().iterator().next().representsNonOptions() ); - } - - /** - * Tells whether the given option was detected. - * - * @param option the option to search for - * @return {@code true} if the option was detected - * @see #has(OptionSpec) - */ - public boolean has( String option ) { - return detectedOptions.containsKey( option ); - } - - /** - * Tells whether the given option was detected. - * - *

This method recognizes only instances of options returned from the fluent interface methods.

- * - *

Specifying a {@linkplain ArgumentAcceptingOptionSpec#defaultsTo(Object, Object[])} default argument value} - * for an option does not cause this method to return {@code true} if the option was not detected on the command - * line.

- * - * @param option the option to search for - * @return {@code true} if the option was detected - * @see #has(String) - */ - public boolean has( OptionSpec option ) { - return optionsToArguments.containsKey( option ); - } - - /** - * Tells whether there are any arguments associated with the given option. - * - * @param option the option to search for - * @return {@code true} if the option was detected and at least one argument was detected for the option - * @see #hasArgument(OptionSpec) - */ - public boolean hasArgument( String option ) { - AbstractOptionSpec spec = detectedOptions.get( option ); - return spec != null && hasArgument( spec ); - } - - /** - * Tells whether there are any arguments associated with the given option. - * - *

This method recognizes only instances of options returned from the fluent interface methods.

- * - *

Specifying a {@linkplain ArgumentAcceptingOptionSpec#defaultsTo(Object, Object[]) default argument value} - * for an option does not cause this method to return {@code true} if the option was not detected on the command - * line, or if the option can take an optional argument but did not have one on the command line.

- * - * @param option the option to search for - * @return {@code true} if the option was detected and at least one argument was detected for the option - * @throws NullPointerException if {@code option} is {@code null} - * @see #hasArgument(String) - */ - public boolean hasArgument( OptionSpec option ) { - requireNonNull( option ); - - List values = optionsToArguments.get( option ); - return values != null && !values.isEmpty(); - } - - /** - * Gives the argument associated with the given option. If the option was given an argument type, the argument - * will take on that type; otherwise, it will be a {@link String}. - * - *

Specifying a {@linkplain ArgumentAcceptingOptionSpec#defaultsTo(Object, Object[]) default argument value} - * for an option will cause this method to return that default value even if the option was not detected on the - * command line, or if the option can take an optional argument but did not have one on the command line.

- * - * @param option the option to search for - * @return the argument of the given option; {@code null} if no argument is present, or that option was not - * detected - * @throws NullPointerException if {@code option} is {@code null} - * @throws OptionException if more than one argument was detected for the option - */ - public Object valueOf( String option ) { - requireNonNull( option ); - - AbstractOptionSpec spec = detectedOptions.get( option ); - if ( spec == null ) { - List defaults = defaultValuesFor( option ); - return defaults.isEmpty() ? null : defaults.get( 0 ); - } - - return valueOf( spec ); - } - - /** - * Gives the argument associated with the given option. - * - *

This method recognizes only instances of options returned from the fluent interface methods.

- * - * @param represents the type of the arguments the given option accepts - * @param option the option to search for - * @return the argument of the given option; {@code null} if no argument is present, or that option was not - * detected - * @throws OptionException if more than one argument was detected for the option - * @throws NullPointerException if {@code option} is {@code null} - * @throws ClassCastException if the arguments of this option are not of the expected type - */ - public V valueOf( OptionSpec option ) { - requireNonNull( option ); - - List values = valuesOf( option ); - switch ( values.size() ) { - case 0: - return null; - case 1: - return values.get( 0 ); - default: - throw new MultipleArgumentsForOptionException( option ); - } - } - - /** - *

Gives any arguments associated with the given option. If the option was given an argument type, the - * arguments will take on that type; otherwise, they will be {@link String}s.

- * - * @param option the option to search for - * @return the arguments associated with the option, as a list of objects of the type given to the arguments; an - * empty list if no such arguments are present, or if the option was not detected - * @throws NullPointerException if {@code option} is {@code null} - */ - public List valuesOf( String option ) { - requireNonNull( option ); - - AbstractOptionSpec spec = detectedOptions.get( option ); - return spec == null ? defaultValuesFor( option ) : valuesOf( spec ); - } - - /** - *

Gives any arguments associated with the given option. If the option was given an argument type, the - * arguments will take on that type; otherwise, they will be {@link String}s.

- * - *

This method recognizes only instances of options returned from the fluent interface methods.

- * - * @param represents the type of the arguments the given option accepts - * @param option the option to search for - * @return the arguments associated with the option; an empty list if no such arguments are present, or if the - * option was not detected - * @throws NullPointerException if {@code option} is {@code null} - * @throws OptionException if there is a problem converting the option's arguments to the desired type; for - * example, if the type does not implement a correct conversion constructor or method - */ - public List valuesOf( OptionSpec option ) { - requireNonNull( option ); - - List values = optionsToArguments.get( option ); - if ( values == null || values.isEmpty() ) - return defaultValueFor( option ); - - AbstractOptionSpec spec = (AbstractOptionSpec) option; - List convertedValues = new ArrayList<>(); - for ( String each : values ) - convertedValues.add( spec.convert( each ) ); - - return unmodifiableList( convertedValues ); - } - - /** - * Gives the set of options that were detected, in the form of {@linkplain OptionSpec}s, in the order in which the - * options were found on the command line. - * - * @return the set of detected command line options - */ - public List> specs() { - List> specs = detectedSpecs; - specs.removeAll( singletonList( detectedOptions.get( NonOptionArgumentSpec.NAME ) ) ); - - return unmodifiableList( specs ); - } - - /** - * Gives all declared options as a map of string to {@linkplain OptionSpec}. - * - * @return the declared options as a map - */ - public Map, List> asMap() { - Map, List> map = new HashMap<>(); - - for ( AbstractOptionSpec spec : recognizedSpecs.values() ) { - if ( !spec.representsNonOptions() ) - map.put( spec, valuesOf( spec ) ); - } - - return unmodifiableMap( map ); - } - - /** - * @return the detected non-option arguments - */ - public List nonOptionArguments() { - AbstractOptionSpec spec = detectedOptions.get( NonOptionArgumentSpec.NAME ); - return valuesOf( spec ); - } - - void add( AbstractOptionSpec spec ) { - addWithArgument( spec, null ); - } - - void addWithArgument( AbstractOptionSpec spec, String argument ) { - detectedSpecs.add( spec ); - - for ( String each : spec.options() ) - detectedOptions.put( each, spec ); - - List optionArguments = optionsToArguments.get( spec ); - - if ( optionArguments == null ) { - optionArguments = new ArrayList<>(); - optionsToArguments.put( spec, optionArguments ); - } - - if ( argument != null ) - optionArguments.add( argument ); - } - - @Override - public boolean equals( Object that ) { - if ( this == that ) - return true; - - if ( that == null || !getClass().equals( that.getClass() ) ) - return false; - - OptionSet other = (OptionSet) that; - Map, List> thisOptionsToArguments = new HashMap<>( optionsToArguments ); - Map, List> otherOptionsToArguments = new HashMap<>( other.optionsToArguments ); - return detectedOptions.equals( other.detectedOptions ) - && thisOptionsToArguments.equals( otherOptionsToArguments ); - } - - @Override - public int hashCode() { - Map, List> thisOptionsToArguments = new HashMap<>( optionsToArguments ); - return detectedOptions.hashCode() ^ thisOptionsToArguments.hashCode(); - } - - @SuppressWarnings( "unchecked" ) - private List defaultValuesFor( String option ) { - if ( defaultValues.containsKey( option ) ) - return unmodifiableList( (List) defaultValues.get( option ) ); - - return emptyList(); - } - - private List defaultValueFor( OptionSpec option ) { - return defaultValuesFor( option.options().iterator().next() ); - } - - private static Map> defaultValues( Map> recognizedSpecs ) { - Map> defaults = new HashMap<>(); - for ( Map.Entry> each : recognizedSpecs.entrySet() ) - defaults.put( each.getKey(), each.getValue().defaultValues() ); - return defaults; - } -} diff --git a/third_party/java/jopt-simple/src/main/java/joptsimple/OptionSpec.java b/third_party/java/jopt-simple/src/main/java/joptsimple/OptionSpec.java deleted file mode 100644 index 70d2d43072..0000000000 --- a/third_party/java/jopt-simple/src/main/java/joptsimple/OptionSpec.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import java.util.List; - -/** - * Describes options that an option parser recognizes. - * - *

Instances of this interface are returned by the "fluent interface" methods to allow retrieval of option arguments - * in a type-safe manner. Here's an example:

- * - *

- *     OptionParser parser = new OptionParser();
- *     OptionSpec<Integer> count =
- *         parser.accepts( "count" ).withRequiredArg().ofType( Integer.class );
- *     OptionSet options = parser.parse( "--count", "2" );
- *     assert options.has( count );
- *     int countValue = options.valueOf( count );
- *     assert countValue == count.value( options );
- *     List<Integer> countValues = options.valuesOf( count );
- *     assert countValues.equals( count.values( options ) );
- * 
- * - * @param represents the type of the arguments this option accepts - * @author Paul Holser - */ -public interface OptionSpec { - /** - * Gives any arguments associated with the given option in the given set of detected options. - * - *

Specifying a {@linkplain ArgumentAcceptingOptionSpec#defaultsTo(Object, Object[]) default argument value} - * for this option will cause this method to return that default value even if this option was not detected on the - * command line, or if this option can take an optional argument but did not have one on the command line.

- * - * @param detectedOptions the detected options to search in - * @return the arguments associated with this option; an empty list if no such arguments are present, or if this - * option was not detected - * @throws OptionException if there is a problem converting this option's arguments to the desired type; for - * example, if the type does not implement a correct conversion constructor or method - * @throws NullPointerException if {@code detectedOptions} is {@code null} - * @see OptionSet#valuesOf(OptionSpec) - */ - List values( OptionSet detectedOptions ); - - /** - * Gives the argument associated with the given option in the given set of detected options. - * - *

Specifying a {@linkplain ArgumentAcceptingOptionSpec#defaultsTo(Object, Object[]) default argument value} - * for this option will cause this method to return that default value even if this option was not detected on the - * command line, or if this option can take an optional argument but did not have one on the command line.

- * - * @param detectedOptions the detected options to search in - * @return the argument of the this option; {@code null} if no argument is present, or that option was not detected - * @throws OptionException if more than one argument was detected for the option - * @throws NullPointerException if {@code detectedOptions} is {@code null} - * @throws ClassCastException if the arguments of this option are not of the expected type - * @see OptionSet#valueOf(OptionSpec) - */ - V value( OptionSet detectedOptions ); - - /** - * @return the string representations of this option - */ - List options(); - - /** - * Tells whether this option is designated as a "help" option. The presence of a "help" option on a command line - * means that missing "required" options will not cause parsing to fail. - * - * @return whether this option is designated as a "help" option - */ - boolean isForHelp(); -} diff --git a/third_party/java/jopt-simple/src/main/java/joptsimple/OptionSpecBuilder.java b/third_party/java/jopt-simple/src/main/java/joptsimple/OptionSpecBuilder.java deleted file mode 100644 index fd5a15a1d6..0000000000 --- a/third_party/java/jopt-simple/src/main/java/joptsimple/OptionSpecBuilder.java +++ /dev/null @@ -1,275 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -/** - * Allows callers to specify whether a given option accepts arguments (required or optional). - * - *

Instances are returned from {@link OptionParser#accepts(String)} to allow the formation of parser directives as - * sentences in a "fluent interface" language. For example:

- * - *

- *   OptionParser parser = new OptionParser();
- *   parser.accepts( "c" ).withRequiredArg().ofType( Integer.class );
- * 
- * - *

If no methods are invoked on an instance of this class, then that instance's option will accept no argument.

- * - *

Note that you should not use the fluent interface clauses in a way that would defeat the typing of option - * arguments:

- * - *

- *   OptionParser parser = new OptionParser();
- *   ArgumentAcceptingOptionSpec<String> optionC =
- *       parser.accepts( "c" ).withRequiredArg();
- *   optionC.ofType( Integer.class );  // DON'T THROW AWAY THE TYPE!
- *
- *   String value = parser.parse( "-c", "2" ).valueOf( optionC );  // ClassCastException
- * 
- * - * @author Paul Holser - */ -public class OptionSpecBuilder extends NoArgumentOptionSpec { - private final OptionParser parser; - - OptionSpecBuilder( OptionParser parser, List options, String description ) { - super( options, description ); - - this.parser = parser; - attachToParser(); - } - - private void attachToParser() { - parser.recognize( this ); - } - - /** - * Informs an option parser that this builder's option requires an argument. - * - * @return a specification for the option - */ - public ArgumentAcceptingOptionSpec withRequiredArg() { - ArgumentAcceptingOptionSpec newSpec = new RequiredArgumentOptionSpec<>( options(), description() ); - parser.recognize( newSpec ); - - return newSpec; - } - - /** - * Informs an option parser that this builder's option accepts an optional argument. - * - * @return a specification for the option - */ - public ArgumentAcceptingOptionSpec withOptionalArg() { - ArgumentAcceptingOptionSpec newSpec = - new OptionalArgumentOptionSpec<>( options(), description() ); - parser.recognize( newSpec ); - - return newSpec; - } - - /** - *

Informs an option parser that this builder's option is required if the given option is present on the command - * line.

- * - *

For a given option, you should not mix this with {@link #requiredUnless(String, String...) - * requiredUnless} to avoid conflicts.

- * - * @param dependent an option whose presence on a command line makes this builder's option required - * @param otherDependents other options whose presence on a command line makes this builder's option required - * @return self, so that the caller can add clauses to the fluent interface sentence - * @throws OptionException if any of the dependent options haven't been configured in the parser yet - */ - public OptionSpecBuilder requiredIf( String dependent, String... otherDependents ) { - List dependents = validatedDependents( dependent, otherDependents ); - for ( String each : dependents ) - parser.requiredIf( options(), each ); - - return this; - } - - /** - *

Informs an option parser that this builder's option is required if the given option is present on the command - * line.

- * - *

For a given option, you should not mix this with {@link #requiredUnless(OptionSpec, OptionSpec[]) - * requiredUnless} to avoid conflicts.

- * - *

This method recognizes only instances of options returned from the fluent interface methods.

- * - * @param dependent the option whose presence on a command line makes this builder's option required - * @param otherDependents other options whose presence on a command line makes this builder's option required - * @return self, so that the caller can add clauses to the fluent interface sentence - */ - public OptionSpecBuilder requiredIf( OptionSpec dependent, OptionSpec... otherDependents ) { - parser.requiredIf( options(), dependent ); - for ( OptionSpec each : otherDependents ) - parser.requiredIf( options(), each ); - - return this; - } - - /** - *

Informs an option parser that this builder's option is required if the given option is absent on the command - * line.

- * - *

For a given option, you should not mix this with {@link #requiredIf(OptionSpec, OptionSpec[]) - * requiredIf} to avoid conflicts.

- * - * @param dependent an option whose absence on a command line makes this builder's option required - * @param otherDependents other options whose absence on a command line makes this builder's option required - * @return self, so that the caller can add clauses to the fluent interface sentence - * @throws OptionException if any of the dependent options haven't been configured in the parser yet - */ - public OptionSpecBuilder requiredUnless( String dependent, String... otherDependents ) { - List dependents = validatedDependents( dependent, otherDependents ); - for ( String each : dependents ) { - parser.requiredUnless( options(), each ); - } - return this; - } - - /** - *

Informs an option parser that this builder's option is required if the given option is absent on the command - * line.

- * - *

For a given option, you should not mix this with {@link #requiredIf(OptionSpec, OptionSpec[]) - * requiredIf} to avoid conflicts.

- * - *

This method recognizes only instances of options returned from the fluent interface methods.

- * - * @param dependent the option whose absence on a command line makes this builder's option required - * @param otherDependents other options whose absence on a command line makes this builder's option required - * @return self, so that the caller can add clauses to the fluent interface sentence - */ - public OptionSpecBuilder requiredUnless( OptionSpec dependent, OptionSpec... otherDependents ) { - parser.requiredUnless( options(), dependent ); - for ( OptionSpec each : otherDependents ) - parser.requiredUnless( options(), each ); - - return this; - } - - /** - *

Informs an option parser that this builder's option is allowed if the given option is present on the command - * line.

- * - *

For a given option, you should not mix this with {@link #availableUnless(String, String...) - * availableUnless} to avoid conflicts.

- * - * @param dependent an option whose presence on a command line makes this builder's option allowed - * @param otherDependents other options whose presence on a command line makes this builder's option allowed - * @return self, so that the caller can add clauses to the fluent interface sentence - * @throws OptionException if any of the dependent options haven't been configured in the parser yet - */ - public OptionSpecBuilder availableIf( String dependent, String... otherDependents ) { - List dependents = validatedDependents( dependent, otherDependents ); - for ( String each : dependents ) - parser.availableIf( options(), each ); - - return this; - } - - /** - *

Informs an option parser that this builder's option is allowed if the given option is present on the command - * line.

- * - *

For a given option, you should not mix this with {@link #availableUnless(OptionSpec, OptionSpec[]) - * requiredUnless} to avoid conflicts.

- * - *

This method recognizes only instances of options returned from the fluent interface methods.

- * - * @param dependent the option whose presence on a command line makes this builder's option allowed - * @param otherDependents other options whose presence on a command line makes this builder's option allowed - * @return self, so that the caller can add clauses to the fluent interface sentence - */ - public OptionSpecBuilder availableIf( OptionSpec dependent, OptionSpec... otherDependents ) { - parser.availableIf( options(), dependent ); - - for ( OptionSpec each : otherDependents ) - parser.availableIf( options(), each ); - - return this; - } - - /** - *

Informs an option parser that this builder's option is allowed if the given option is absent on the command - * line.

- * - *

For a given option, you should not mix this with {@link #availableIf(OptionSpec, OptionSpec[]) - * requiredIf} to avoid conflicts.

- * - * @param dependent an option whose absence on a command line makes this builder's option allowed - * @param otherDependents other options whose absence on a command line makes this builder's option allowed - * @return self, so that the caller can add clauses to the fluent interface sentence - * @throws OptionException if any of the dependent options haven't been configured in the parser yet - */ - public OptionSpecBuilder availableUnless( String dependent, String... otherDependents ) { - List dependents = validatedDependents( dependent, otherDependents ); - for ( String each : dependents ) - parser.availableUnless( options(), each ); - - return this; - } - - /** - *

Informs an option parser that this builder's option is allowed if the given option is absent on the command - * line.

- * - *

For a given option, you should not mix this with {@link #availableIf(OptionSpec, OptionSpec[]) - * requiredIf} to avoid conflicts.

- * - *

This method recognizes only instances of options returned from the fluent interface methods.

- * - * @param dependent the option whose absence on a command line makes this builder's option allowed - * @param otherDependents other options whose absence on a command line makes this builder's option allowed - * @return self, so that the caller can add clauses to the fluent interface sentence - */ - public OptionSpecBuilder availableUnless( OptionSpec dependent, OptionSpec... otherDependents ) { - parser.availableUnless( options(), dependent ); - for ( OptionSpec each : otherDependents ) - parser.availableUnless(options(), each); - - return this; - } - - private List validatedDependents( String dependent, String... otherDependents ) { - List dependents = new ArrayList<>(); - dependents.add( dependent ); - Collections.addAll( dependents, otherDependents ); - - for ( String each : dependents ) { - if ( !parser.isRecognized( each ) ) - throw new UnconfiguredOptionException( each ); - } - - return dependents; - } -} diff --git a/third_party/java/jopt-simple/src/main/java/joptsimple/OptionSpecTokenizer.java b/third_party/java/jopt-simple/src/main/java/joptsimple/OptionSpecTokenizer.java deleted file mode 100644 index f9e4606c0c..0000000000 --- a/third_party/java/jopt-simple/src/main/java/joptsimple/OptionSpecTokenizer.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import java.util.NoSuchElementException; - -import static joptsimple.ParserRules.*; - -/** - * Tokenizes a short option specification string. - * - * @author Paul Holser - */ -class OptionSpecTokenizer { - private static final char POSIXLY_CORRECT_MARKER = '+'; - private static final char HELP_MARKER = '*'; - - private String specification; - private int index; - - OptionSpecTokenizer( String specification ) { - if ( specification == null ) - throw new NullPointerException( "null option specification" ); - - this.specification = specification; - } - - boolean hasMore() { - return index < specification.length(); - } - - AbstractOptionSpec next() { - if ( !hasMore() ) - throw new NoSuchElementException(); - - - String optionCandidate = String.valueOf( specification.charAt( index ) ); - index++; - - AbstractOptionSpec spec; - if ( RESERVED_FOR_EXTENSIONS.equals( optionCandidate ) ) { - spec = handleReservedForExtensionsToken(); - - if ( spec != null ) - return spec; - } - - ensureLegalOption( optionCandidate ); - - if ( hasMore() ) { - boolean forHelp = false; - if ( specification.charAt( index ) == HELP_MARKER ) { - forHelp = true; - ++index; - } - spec = hasMore() && specification.charAt( index ) == ':' - ? handleArgumentAcceptingOption( optionCandidate ) - : new NoArgumentOptionSpec( optionCandidate ); - if ( forHelp ) - spec.forHelp(); - } else - spec = new NoArgumentOptionSpec( optionCandidate ); - - return spec; - } - - void configure( OptionParser parser ) { - adjustForPosixlyCorrect( parser ); - - while ( hasMore() ) - parser.recognize( next() ); - } - - private void adjustForPosixlyCorrect( OptionParser parser ) { - if ( POSIXLY_CORRECT_MARKER == specification.charAt( 0 ) ) { - parser.posixlyCorrect( true ); - specification = specification.substring( 1 ); - } - } - - private AbstractOptionSpec handleReservedForExtensionsToken() { - if ( !hasMore() ) - return new NoArgumentOptionSpec( RESERVED_FOR_EXTENSIONS ); - - if ( specification.charAt( index ) == ';' ) { - ++index; - return new AlternativeLongOptionSpec(); - } - - return null; - } - - private AbstractOptionSpec handleArgumentAcceptingOption( String candidate ) { - index++; - - if ( hasMore() && specification.charAt( index ) == ':' ) { - index++; - return new OptionalArgumentOptionSpec( candidate ); - } - - return new RequiredArgumentOptionSpec( candidate ); - } -} diff --git a/third_party/java/jopt-simple/src/main/java/joptsimple/OptionalArgumentOptionSpec.java b/third_party/java/jopt-simple/src/main/java/joptsimple/OptionalArgumentOptionSpec.java deleted file mode 100644 index cd641ed580..0000000000 --- a/third_party/java/jopt-simple/src/main/java/joptsimple/OptionalArgumentOptionSpec.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import java.util.List; - -/** - * Specification of an option that accepts an optional argument. - * - * @param represents the type of the arguments this option accepts - * @author Paul Holser - */ -class OptionalArgumentOptionSpec extends ArgumentAcceptingOptionSpec { - OptionalArgumentOptionSpec( String option ) { - super( option, false ); - } - - OptionalArgumentOptionSpec( List options, String description ) { - super( options, false, description ); - } - - @Override - protected void detectOptionArgument( OptionParser parser, ArgumentList arguments, OptionSet detectedOptions ) { - if ( arguments.hasMore() ) { - String nextArgument = arguments.peek(); - - if ( !parser.looksLikeAnOption( nextArgument ) && canConvertArgument( nextArgument ) ) - handleOptionArgument( parser, detectedOptions, arguments ); - else if ( isArgumentOfNumberType() && canConvertArgument( nextArgument ) ) - addArguments( detectedOptions, arguments.next() ); - else - detectedOptions.add( this ); - } - else - detectedOptions.add( this ); - } - - private void handleOptionArgument( OptionParser parser, OptionSet detectedOptions, ArgumentList arguments ) { - if ( parser.posixlyCorrect() ) { - detectedOptions.add( this ); - parser.noMoreOptions(); - } - else - addArguments( detectedOptions, arguments.next() ); - } -} diff --git a/third_party/java/jopt-simple/src/main/java/joptsimple/ParserRules.java b/third_party/java/jopt-simple/src/main/java/joptsimple/ParserRules.java deleted file mode 100644 index 34ef7814d5..0000000000 --- a/third_party/java/jopt-simple/src/main/java/joptsimple/ParserRules.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import java.util.List; - -import static java.lang.Character.*; - -/** - * Can tell whether or not options are well-formed. - * - * @author Paul Holser - */ -final class ParserRules { - static final char HYPHEN_CHAR = '-'; - static final String HYPHEN = String.valueOf( HYPHEN_CHAR ); - static final String DOUBLE_HYPHEN = "--"; - static final String OPTION_TERMINATOR = DOUBLE_HYPHEN; - static final String RESERVED_FOR_EXTENSIONS = "W"; - - private ParserRules() { - throw new UnsupportedOperationException(); - } - - static boolean isShortOptionToken( String argument ) { - return argument.startsWith( HYPHEN ) - && !HYPHEN.equals( argument ) - && !isLongOptionToken( argument ); - } - - static boolean isLongOptionToken( String argument ) { - return argument.startsWith( DOUBLE_HYPHEN ) && !isOptionTerminator( argument ); - } - - static boolean isOptionTerminator( String argument ) { - return OPTION_TERMINATOR.equals( argument ); - } - - static void ensureLegalOption( String option ) { - if ( option.startsWith( HYPHEN ) ) - throw new IllegalOptionSpecificationException( String.valueOf( option ) ); - - for ( int i = 0; i < option.length(); ++i ) - ensureLegalOptionCharacter( option.charAt( i ) ); - } - - static void ensureLegalOptions( List options ) { - for ( String each : options ) - ensureLegalOption( each ); - } - - private static void ensureLegalOptionCharacter( char option ) { - if ( !( isLetterOrDigit( option ) || isAllowedPunctuation( option ) ) ) - throw new IllegalOptionSpecificationException( String.valueOf( option ) ); - } - - private static boolean isAllowedPunctuation( char option ) { - String allowedPunctuation = "?._" + HYPHEN_CHAR; - return allowedPunctuation.indexOf( option ) != -1; - } -} diff --git a/third_party/java/jopt-simple/src/main/java/joptsimple/RequiredArgumentOptionSpec.java b/third_party/java/jopt-simple/src/main/java/joptsimple/RequiredArgumentOptionSpec.java deleted file mode 100644 index 4c7ab880c7..0000000000 --- a/third_party/java/jopt-simple/src/main/java/joptsimple/RequiredArgumentOptionSpec.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import java.util.List; - -/** - * Specification of an option that accepts a required argument. - * - * @param represents the type of the arguments this option accepts - * @author Paul Holser - */ -class RequiredArgumentOptionSpec extends ArgumentAcceptingOptionSpec { - RequiredArgumentOptionSpec( String option ) { - super( option, true ); - } - - RequiredArgumentOptionSpec( List options, String description ) { - super( options, true, description ); - } - - @Override - protected void detectOptionArgument( OptionParser parser, ArgumentList arguments, OptionSet detectedOptions ) { - if ( !arguments.hasMore() ) - throw new OptionMissingRequiredArgumentException( this ); - - addArguments( detectedOptions, arguments.next() ); - } -} diff --git a/third_party/java/jopt-simple/src/main/java/joptsimple/UnavailableOptionException.java b/third_party/java/jopt-simple/src/main/java/joptsimple/UnavailableOptionException.java deleted file mode 100644 index b1fa0e3a1e..0000000000 --- a/third_party/java/jopt-simple/src/main/java/joptsimple/UnavailableOptionException.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import java.util.List; - -/** - * Thrown when options marked as allowed are specified on the command line, but the options they depend upon are - * present/not present. - */ -class UnavailableOptionException extends OptionException { - private static final long serialVersionUID = -1L; - - UnavailableOptionException( List> forbiddenOptions ) { - super( forbiddenOptions ); - } - - @Override - Object[] messageArguments() { - return new Object[] { multipleOptionString() }; - } -} diff --git a/third_party/java/jopt-simple/src/main/java/joptsimple/UnconfiguredOptionException.java b/third_party/java/jopt-simple/src/main/java/joptsimple/UnconfiguredOptionException.java deleted file mode 100644 index f62d88bd4a..0000000000 --- a/third_party/java/jopt-simple/src/main/java/joptsimple/UnconfiguredOptionException.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import java.util.List; - -import static java.util.Collections.*; - -/** - * Thrown when an option parser refers to an option that is not in fact configured already on the parser. - * - * @author Paul Holser - */ -class UnconfiguredOptionException extends OptionException { - private static final long serialVersionUID = -1L; - - UnconfiguredOptionException( String option ) { - this( singletonList( option ) ); - } - - UnconfiguredOptionException( List options ) { - super( options ); - } - - @Override - Object[] messageArguments() { - return new Object[] { multipleOptionString() }; - } -} diff --git a/third_party/java/jopt-simple/src/main/java/joptsimple/UnrecognizedOptionException.java b/third_party/java/jopt-simple/src/main/java/joptsimple/UnrecognizedOptionException.java deleted file mode 100644 index 73e7d74a0b..0000000000 --- a/third_party/java/jopt-simple/src/main/java/joptsimple/UnrecognizedOptionException.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -import static java.util.Collections.*; - -/** - * Thrown when the option parser encounters an unrecognized option. - * - * @author Paul Holser - */ -class UnrecognizedOptionException extends OptionException { - private static final long serialVersionUID = -1L; - - UnrecognizedOptionException( String option ) { - super( singletonList( option ) ); - } - - @Override - Object[] messageArguments() { - return new Object[] { singleOptionString() }; - } -} diff --git a/third_party/java/jopt-simple/src/main/java/joptsimple/ValueConversionException.java b/third_party/java/jopt-simple/src/main/java/joptsimple/ValueConversionException.java deleted file mode 100644 index 50d575d194..0000000000 --- a/third_party/java/jopt-simple/src/main/java/joptsimple/ValueConversionException.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -/** - * Thrown by {@link ValueConverter}s when problems occur in converting string values to other Java types. - * - * @author Paul Holser - */ -public class ValueConversionException extends RuntimeException { - private static final long serialVersionUID = -1L; - - /** - * Creates a new exception with the specified detail message. - * - * @param message the detail message - */ - public ValueConversionException( String message ) { - this( message, null ); - } - - /** - * Creates a new exception with the specified detail message and cause. - * - * @param message the detail message - * @param cause the original exception - */ - public ValueConversionException( String message, Throwable cause ) { - super( message, cause ); - } -} diff --git a/third_party/java/jopt-simple/src/main/java/joptsimple/ValueConverter.java b/third_party/java/jopt-simple/src/main/java/joptsimple/ValueConverter.java deleted file mode 100644 index bc968da2d8..0000000000 --- a/third_party/java/jopt-simple/src/main/java/joptsimple/ValueConverter.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple; - -/** - * Instances of this interface are used to convert arguments of options into specific Java types. - * - * @param constraint on the type of values being converted to - * @author Paul Holser - */ -public interface ValueConverter { - /** - * Converts the given string value into a Java type. - * - * @param value the string to convert - * @return the converted value - * @throws ValueConversionException if a problem occurs while converting the value - */ - V convert( String value ); - - /** - * Gives the class of the type of values this converter converts to. - * - * @return the target class for conversion - */ - Class valueType(); - - /** - * Gives a string that describes the pattern of the values this converter expects, if any. For example, a date - * converter can respond with a {@link java.text.SimpleDateFormat date format string}. - * - * @return a value pattern, or {@code null} if there's nothing interesting here - */ - String valuePattern(); -} diff --git a/third_party/java/jopt-simple/src/main/java/joptsimple/internal/AbbreviationMap.java b/third_party/java/jopt-simple/src/main/java/joptsimple/internal/AbbreviationMap.java deleted file mode 100644 index 0d601839a5..0000000000 --- a/third_party/java/jopt-simple/src/main/java/joptsimple/internal/AbbreviationMap.java +++ /dev/null @@ -1,242 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple.internal; - -import java.util.Map; -import java.util.TreeMap; - -/** - *

A map whose keys are strings; when a key/value pair is added to the map, the longest unique abbreviations of that - * key are added as well, and associated with the value. Thus:

- * - *
- *   
- *   abbreviations.put( "good", "bye" );
- *   
- * 
- * - *

would make it such that you could retrieve the value {@code "bye"} from the map using the keys {@code "good"}, - * {@code "goo"}, {@code "go"}, and {@code "g"}. A subsequent invocation of:

- *
- *   
- *   abbreviations.put( "go", "fish" );
- *   
- * 
- * - *

would make it such that you could retrieve the value {@code "bye"} using the keys {@code "good"} and - * {@code "goo"}, and the value {@code "fish"} using the key {@code "go"}. The key {@code "g"} would yield - * {@code null}, since it would no longer be a unique abbreviation.

- * - *

The data structure is much like a "trie".

- * - * @param a constraint on the types of the values in the map - * @author Paul Holser - * @see Perl's Text::Abbrev module - * @see Radix tree - */ -public class AbbreviationMap implements OptionNameMap { - private final Map> children = new TreeMap<>(); - - private String key; - private V value; - private int keysBeyond; - - /** - *

Tells whether the given key is in the map, or whether the given key is a unique - * abbreviation of a key that is in the map.

- * - * @param key key to look up - * @return {@code true} if {@code key} is present in the map - * @throws NullPointerException if {@code key} is {@code null} - */ - @Override - public boolean contains(String key) { - return get(key) != null; - } - - /** - *

Answers the value associated with the given key. The key can be a unique - * abbreviation of a key that is in the map.

- * - * @param key key to look up - * @return the value associated with {@code aKey}; or {@code null} if there is no - * such value or {@code aKey} is not a unique abbreviation of a key in the map - * @throws NullPointerException if {@code aKey} is {@code null} - */ - @Override - public V get( String key ) { - char[] chars = charsOf( key ); - - AbbreviationMap child = this; - for ( char each : chars ) { - child = child.children.get( each ); - if ( child == null ) - return null; - } - - return child.value; - } - - /** - *

Associates a given value with a given key. If there was a previous - * association, the old value is replaced with the new one.

- * - * @param key key to create in the map - * @param newValue value to associate with the key - * @throws NullPointerException if {@code aKey} or {@code newValue} is {@code null} - * @throws IllegalArgumentException if {@code aKey} is a zero-length string - */ - @Override - public void put( String key, V newValue ) { - if ( newValue == null ) - throw new NullPointerException(); - if ( key.length() == 0 ) - throw new IllegalArgumentException(); - - char[] chars = charsOf(key); - add( chars, newValue, 0, chars.length ); - } - - /** - *

Associates a given value with a given set of keys. If there was a previous - * association, the old value is replaced with the new one.

- * - * @param keys keys to create in the map - * @param newValue value to associate with the key - * @throws NullPointerException if {@code keys} or {@code newValue} is {@code null} - * @throws IllegalArgumentException if any of {@code keys} is a zero-length string - */ - @Override - public void putAll( Iterable keys, V newValue ) { - for ( String each : keys ) - put( each, newValue ); - } - - private boolean add( char[] chars, V newValue, int offset, int length ) { - if ( offset == length ) { - value = newValue; - boolean wasAlreadyAKey = key != null; - key = new String( chars ); - return !wasAlreadyAKey; - } - - char nextChar = chars[ offset ]; - AbbreviationMap child = children.get( nextChar ); - if ( child == null ) { - child = new AbbreviationMap<>(); - children.put( nextChar, child ); - } - - boolean newKeyAdded = child.add( chars, newValue, offset + 1, length ); - - if ( newKeyAdded ) - ++keysBeyond; - - if ( key == null ) - value = keysBeyond > 1 ? null : newValue; - - return newKeyAdded; - } - - /** - *

If the map contains the given key, dissociates the key from its value.

- * - * @param key key to remove - * @throws NullPointerException if {@code aKey} is {@code null} - * @throws IllegalArgumentException if {@code aKey} is a zero-length string - */ - @Override - public void remove( String key ) { - if ( key.length() == 0 ) - throw new IllegalArgumentException(); - - char[] keyChars = charsOf(key); - remove( keyChars, 0, keyChars.length ); - } - - private boolean remove( char[] aKey, int offset, int length ) { - if ( offset == length ) - return removeAtEndOfKey(); - - char nextChar = aKey[ offset ]; - AbbreviationMap child = children.get( nextChar ); - if ( child == null || !child.remove( aKey, offset + 1, length ) ) - return false; - - --keysBeyond; - if ( child.keysBeyond == 0 ) - children.remove( nextChar ); - if ( keysBeyond == 1 && key == null ) - setValueToThatOfOnlyChild(); - - return true; - } - - private void setValueToThatOfOnlyChild() { - Map.Entry> entry = children.entrySet().iterator().next(); - AbbreviationMap onlyChild = entry.getValue(); - value = onlyChild.value; - } - - private boolean removeAtEndOfKey() { - if ( key == null ) - return false; - - key = null; - if ( keysBeyond == 1 ) - setValueToThatOfOnlyChild(); - else - value = null; - - return true; - } - - /** - * Gives a Java map representation of this abbreviation map. - * - * @return a Java map corresponding to this abbreviation map - */ - @Override - public Map toJavaUtilMap() { - Map mappings = new TreeMap<>(); - addToMappings( mappings ); - return mappings; - } - - private void addToMappings( Map mappings ) { - if ( key != null ) - mappings.put( key, value ); - - for ( AbbreviationMap each : children.values() ) - each.addToMappings( mappings ); - } - - private static char[] charsOf( String aKey ) { - char[] chars = new char[ aKey.length() ]; - aKey.getChars( 0, aKey.length(), chars, 0 ); - return chars; - } -} diff --git a/third_party/java/jopt-simple/src/main/java/joptsimple/internal/Classes.java b/third_party/java/jopt-simple/src/main/java/joptsimple/internal/Classes.java deleted file mode 100644 index f7030f88cb..0000000000 --- a/third_party/java/jopt-simple/src/main/java/joptsimple/internal/Classes.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple.internal; - -import java.util.HashMap; -import java.util.Map; - -/** - * @author Paul Holser - */ -public final class Classes { - private static final Map, Class> WRAPPERS = new HashMap<>( 13 ); - - static { - WRAPPERS.put( boolean.class, Boolean.class ); - WRAPPERS.put( byte.class, Byte.class ); - WRAPPERS.put( char.class, Character.class ); - WRAPPERS.put( double.class, Double.class ); - WRAPPERS.put( float.class, Float.class ); - WRAPPERS.put( int.class, Integer.class ); - WRAPPERS.put( long.class, Long.class ); - WRAPPERS.put( short.class, Short.class ); - WRAPPERS.put( void.class, Void.class ); - } - - private Classes() { - throw new UnsupportedOperationException(); - } - - /** - * Gives the "short version" of the given class name. Somewhat naive to inner classes. - * - * @param className class name to chew on - * @return the short name of the class - */ - public static String shortNameOf( String className ) { - return className.substring( className.lastIndexOf( '.' ) + 1 ); - } - - /** - * Gives the primitive wrapper class for the given class. If the given class is not - * {@linkplain Class#isPrimitive() primitive}, returns the class itself. - * - * @param generic class type - * @param clazz the class to check - * @return primitive wrapper type if {@code clazz} is primitive, otherwise {@code clazz} - */ - @SuppressWarnings( "unchecked" ) - public static Class wrapperOf( Class clazz ) { - return clazz.isPrimitive() ? (Class) WRAPPERS.get( clazz ) : clazz; - } -} diff --git a/third_party/java/jopt-simple/src/main/java/joptsimple/internal/Columns.java b/third_party/java/jopt-simple/src/main/java/joptsimple/internal/Columns.java deleted file mode 100644 index a012b601f0..0000000000 --- a/third_party/java/jopt-simple/src/main/java/joptsimple/internal/Columns.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple.internal; - -import java.text.BreakIterator; -import java.util.ArrayList; -import java.util.List; - -import static java.text.BreakIterator.*; - -import static joptsimple.internal.Strings.*; - -/** - * @author Paul Holser - */ -class Columns { - private static final int INDENT_WIDTH = 2; - - private final int optionWidth; - private final int descriptionWidth; - - Columns( int optionWidth, int descriptionWidth ) { - this.optionWidth = optionWidth; - this.descriptionWidth = descriptionWidth; - } - - List fit( Row row ) { - List options = piecesOf( row.option, optionWidth ); - List descriptions = piecesOf( row.description, descriptionWidth ); - - List rows = new ArrayList<>(); - for ( int i = 0; i < Math.max( options.size(), descriptions.size() ); ++i ) - rows.add( new Row( itemOrEmpty( options, i ), itemOrEmpty( descriptions, i ) ) ); - - return rows; - } - - private static String itemOrEmpty( List items, int index ) { - return index >= items.size() ? "" : items.get( index ); - } - - private List piecesOf( String raw, int width ) { - List pieces = new ArrayList<>(); - - for ( String each : raw.trim().split( LINE_SEPARATOR ) ) - pieces.addAll( piecesOfEmbeddedLine( each, width ) ); - - return pieces; - } - - private List piecesOfEmbeddedLine( String line, int width ) { - List pieces = new ArrayList<>(); - - BreakIterator words = BreakIterator.getLineInstance(); - words.setText( line ); - - StringBuilder nextPiece = new StringBuilder(); - - int start = words.first(); - for ( int end = words.next(); end != DONE; start = end, end = words.next() ) - nextPiece = processNextWord( line, nextPiece, start, end, width, pieces ); - - if ( nextPiece.length() > 0 ) - pieces.add( nextPiece.toString() ); - - return pieces; - } - - private StringBuilder processNextWord( String source, StringBuilder nextPiece, int start, int end, int width, - List pieces ) { - StringBuilder augmented = nextPiece; - - String word = source.substring( start, end ); - if ( augmented.length() + word.length() > width ) { - pieces.add( augmented.toString().replaceAll( "\\s+$", "" ) ); - augmented = new StringBuilder( repeat( ' ', INDENT_WIDTH ) ).append( word ); - } - else - augmented.append( word ); - - return augmented; - } -} diff --git a/third_party/java/jopt-simple/src/main/java/joptsimple/internal/ConstructorInvokingValueConverter.java b/third_party/java/jopt-simple/src/main/java/joptsimple/internal/ConstructorInvokingValueConverter.java deleted file mode 100644 index d3a641b57d..0000000000 --- a/third_party/java/jopt-simple/src/main/java/joptsimple/internal/ConstructorInvokingValueConverter.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple.internal; - -import java.lang.reflect.Constructor; - -import joptsimple.ValueConverter; - -import static joptsimple.internal.Reflection.*; - -/** - * @param constraint on the type of values being converted to - * @author Paul Holser - */ -class ConstructorInvokingValueConverter implements ValueConverter { - private final Constructor ctor; - - ConstructorInvokingValueConverter( Constructor ctor ) { - this.ctor = ctor; - } - - public V convert( String value ) { - return instantiate( ctor, value ); - } - - public Class valueType() { - return ctor.getDeclaringClass(); - } - - public String valuePattern() { - return null; - } -} diff --git a/third_party/java/jopt-simple/src/main/java/joptsimple/internal/Messages.java b/third_party/java/jopt-simple/src/main/java/joptsimple/internal/Messages.java deleted file mode 100644 index 5bb71fc727..0000000000 --- a/third_party/java/jopt-simple/src/main/java/joptsimple/internal/Messages.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple.internal; - -import java.text.MessageFormat; -import java.util.Locale; -import java.util.ResourceBundle; - -/** - * @author Paul Holser - */ -public class Messages { - private Messages() { - throw new UnsupportedOperationException(); - } - - public static String message( Locale locale, String bundleName, Class type, String key, Object... args ) { - ResourceBundle bundle = ResourceBundle.getBundle( bundleName, locale ); - String template = bundle.getString( type.getName() + '.' + key ); - MessageFormat format = new MessageFormat( template ); - format.setLocale( locale ); - return format.format( args ); - } -} diff --git a/third_party/java/jopt-simple/src/main/java/joptsimple/internal/MethodInvokingValueConverter.java b/third_party/java/jopt-simple/src/main/java/joptsimple/internal/MethodInvokingValueConverter.java deleted file mode 100644 index 503d6778d8..0000000000 --- a/third_party/java/jopt-simple/src/main/java/joptsimple/internal/MethodInvokingValueConverter.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple.internal; - -import java.lang.reflect.Method; - -import joptsimple.ValueConverter; - -import static joptsimple.internal.Reflection.*; - -/** - * @param constraint on the type of values being converted to - * @author Paul Holser - */ -class MethodInvokingValueConverter implements ValueConverter { - private final Method method; - private final Class clazz; - - MethodInvokingValueConverter( Method method, Class clazz ) { - this.method = method; - this.clazz = clazz; - } - - public V convert( String value ) { - return clazz.cast( invoke( method, value ) ); - } - - public Class valueType() { - return clazz; - } - - public String valuePattern() { - return null; - } -} diff --git a/third_party/java/jopt-simple/src/main/java/joptsimple/internal/OptionNameMap.java b/third_party/java/jopt-simple/src/main/java/joptsimple/internal/OptionNameMap.java deleted file mode 100644 index 1b9e49197b..0000000000 --- a/third_party/java/jopt-simple/src/main/java/joptsimple/internal/OptionNameMap.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple.internal; - -import java.util.Map; - -/** - * Map-like interface for storing String-value pairs. - * - * @param type of values stored in the map - */ -public interface OptionNameMap { - boolean contains( String key ); - - V get( String key ); - - void put( String key, V newValue ); - - void putAll( Iterable keys, V newValue ); - - void remove( String key ); - - Map toJavaUtilMap(); -} diff --git a/third_party/java/jopt-simple/src/main/java/joptsimple/internal/Reflection.java b/third_party/java/jopt-simple/src/main/java/joptsimple/internal/Reflection.java deleted file mode 100644 index 5dad882787..0000000000 --- a/third_party/java/jopt-simple/src/main/java/joptsimple/internal/Reflection.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple.internal; - -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -import static java.lang.reflect.Modifier.*; - -import joptsimple.ValueConverter; - -import static joptsimple.internal.Classes.*; - -/** - * Helper methods for reflection. - * - * @author Paul Holser - */ -public final class Reflection { - private Reflection() { - throw new UnsupportedOperationException(); - } - - /** - * Finds an appropriate value converter for the given class. - * - * @param a constraint on the class object to introspect - * @param clazz class to introspect on - * @return a converter method or constructor - */ - public static ValueConverter findConverter( Class clazz ) { - Class maybeWrapper = wrapperOf( clazz ); - - ValueConverter valueOf = valueOfConverter( maybeWrapper ); - if ( valueOf != null ) - return valueOf; - - ValueConverter constructor = constructorConverter( maybeWrapper ); - if ( constructor != null ) - return constructor; - - throw new IllegalArgumentException( clazz + " is not a value type" ); - } - - private static ValueConverter valueOfConverter( Class clazz ) { - try { - Method valueOf = clazz.getMethod( "valueOf", String.class ); - if ( meetsConverterRequirements( valueOf, clazz ) ) - return new MethodInvokingValueConverter<>( valueOf, clazz ); - - return null; - } catch ( NoSuchMethodException ignored ) { - return null; - } - } - - private static ValueConverter constructorConverter( Class clazz ) { - try { - return new ConstructorInvokingValueConverter<>( clazz.getConstructor( String.class ) ); - } catch ( NoSuchMethodException ignored ) { - return null; - } - } - - /** - * Invokes the given constructor with the given arguments. - * - * @param constraint on the type of the objects yielded by the constructor - * @param constructor constructor to invoke - * @param args arguments to hand to the constructor - * @return the result of invoking the constructor - * @throws ReflectionException in lieu of the gaggle of reflection-related exceptions - */ - public static T instantiate( Constructor constructor, Object... args ) { - try { - return constructor.newInstance( args ); - } catch ( Exception ex ) { - throw reflectionException( ex ); - } - } - - /** - * Invokes the given static method with the given arguments. - * - * @param method method to invoke - * @param args arguments to hand to the method - * @return the result of invoking the method - * @throws ReflectionException in lieu of the gaggle of reflection-related exceptions - */ - public static Object invoke( Method method, Object... args ) { - try { - return method.invoke( null, args ); - } catch ( Exception ex ) { - throw reflectionException( ex ); - } - } - - @SuppressWarnings( "unchecked" ) - public static V convertWith( ValueConverter converter, String raw ) { - return converter == null ? (V) raw : converter.convert( raw ); - } - - private static boolean meetsConverterRequirements( Method method, Class expectedReturnType ) { - int modifiers = method.getModifiers(); - return isPublic( modifiers ) && isStatic( modifiers ) && expectedReturnType.equals( method.getReturnType() ); - } - - private static RuntimeException reflectionException( Exception ex ) { - if ( ex instanceof IllegalArgumentException ) - return new ReflectionException( ex ); - if ( ex instanceof InvocationTargetException ) - return new ReflectionException( ex.getCause() ); - if ( ex instanceof RuntimeException ) - return (RuntimeException) ex; - - return new ReflectionException( ex ); - } -} diff --git a/third_party/java/jopt-simple/src/main/java/joptsimple/internal/ReflectionException.java b/third_party/java/jopt-simple/src/main/java/joptsimple/internal/ReflectionException.java deleted file mode 100644 index 17cd4d6330..0000000000 --- a/third_party/java/jopt-simple/src/main/java/joptsimple/internal/ReflectionException.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple.internal; - -/** - * This unchecked exception wraps reflection-oriented exceptions. - * - * @author Paul Holser - */ -public class ReflectionException extends RuntimeException { - private static final long serialVersionUID = -2L; - - ReflectionException( Throwable cause ) { - super( cause ); - } -} diff --git a/third_party/java/jopt-simple/src/main/java/joptsimple/internal/Row.java b/third_party/java/jopt-simple/src/main/java/joptsimple/internal/Row.java deleted file mode 100644 index 13d8e34905..0000000000 --- a/third_party/java/jopt-simple/src/main/java/joptsimple/internal/Row.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple.internal; - -/** - * @author Paul Holser - */ -class Row { - final String option; - final String description; - - Row( String option, String description ) { - this.option = option; - this.description = description; - } - - @Override - public boolean equals( Object that ) { - if ( that == this ) - return true; - if ( that == null || !getClass().equals( that.getClass() ) ) - return false; - - Row other = (Row) that; - return option.equals( other.option ) && description.equals( other.description ); - } - - @Override - public int hashCode() { - return option.hashCode() ^ description.hashCode(); - } -} diff --git a/third_party/java/jopt-simple/src/main/java/joptsimple/internal/Rows.java b/third_party/java/jopt-simple/src/main/java/joptsimple/internal/Rows.java deleted file mode 100644 index c2cae82ce4..0000000000 --- a/third_party/java/jopt-simple/src/main/java/joptsimple/internal/Rows.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple.internal; - -import java.util.ArrayList; -import java.util.List; - -import static java.lang.Math.*; - -import static joptsimple.internal.Strings.*; - -/** - * @author Paul Holser - */ -public class Rows { - private final int overallWidth; - private final int columnSeparatorWidth; - private final List rows = new ArrayList<>(); - - private int widthOfWidestOption; - private int widthOfWidestDescription; - - public Rows( int overallWidth, int columnSeparatorWidth ) { - this.overallWidth = overallWidth; - this.columnSeparatorWidth = columnSeparatorWidth; - } - - public void add( String option, String description ) { - add( new Row( option, description ) ); - } - - private void add( Row row ) { - rows.add( row ); - widthOfWidestOption = max( widthOfWidestOption, row.option.length() ); - widthOfWidestDescription = max( widthOfWidestDescription, row.description.length() ); - } - - public void reset() { - rows.clear(); - widthOfWidestOption = 0; - widthOfWidestDescription = 0; - } - - public void fitToWidth() { - Columns columns = new Columns( optionWidth(), descriptionWidth() ); - - List fitted = new ArrayList<>(); - for ( Row each : rows ) - fitted.addAll( columns.fit( each ) ); - - reset(); - - for ( Row each : fitted ) - add( each ); - } - - public String render() { - StringBuilder buffer = new StringBuilder(); - - for ( Row each : rows ) { - pad( buffer, each.option, optionWidth() ).append( repeat( ' ', columnSeparatorWidth ) ); - pad( buffer, each.description, descriptionWidth() ).append( LINE_SEPARATOR ); - } - - return buffer.toString(); - } - - private int optionWidth() { - return min( ( overallWidth - columnSeparatorWidth ) / 2, widthOfWidestOption ); - } - - private int descriptionWidth() { - return min( overallWidth - optionWidth() - columnSeparatorWidth, widthOfWidestDescription ); - } - - private StringBuilder pad( StringBuilder buffer, String s, int length ) { - buffer.append( s ).append( repeat( ' ', length - s.length() ) ); - return buffer; - } -} diff --git a/third_party/java/jopt-simple/src/main/java/joptsimple/internal/SimpleOptionNameMap.java b/third_party/java/jopt-simple/src/main/java/joptsimple/internal/SimpleOptionNameMap.java deleted file mode 100644 index 69ad6b5c4c..0000000000 --- a/third_party/java/jopt-simple/src/main/java/joptsimple/internal/SimpleOptionNameMap.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple.internal; - -import java.util.HashMap; -import java.util.Map; - -/** - *

An {@code OptionNameMap} which wraps and behaves like {@code HashMap}.

- */ -public class SimpleOptionNameMap implements OptionNameMap { - private final Map map = new HashMap<>(); - - @Override - public boolean contains( String key ) { - return map.containsKey( key ); - } - - @Override - public V get( String key ) { - return map.get( key ); - } - - @Override - public void put( String key, V newValue ) { - map.put( key, newValue ); - } - - @Override - public void putAll( Iterable keys, V newValue ) { - for ( String each : keys ) - map.put( each, newValue ); - } - - @Override - public void remove( String key ) { - map.remove( key ); - } - - @Override - public Map toJavaUtilMap() { - return new HashMap<>( map ); - } -} diff --git a/third_party/java/jopt-simple/src/main/java/joptsimple/internal/Strings.java b/third_party/java/jopt-simple/src/main/java/joptsimple/internal/Strings.java deleted file mode 100644 index 50ea3e49ea..0000000000 --- a/third_party/java/jopt-simple/src/main/java/joptsimple/internal/Strings.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple.internal; - -import java.util.Iterator; - -import static java.lang.System.*; -import static java.util.Arrays.*; - -/** - * @author Paul Holser - */ -public final class Strings { - public static final String EMPTY = ""; - public static final String LINE_SEPARATOR = getProperty( "line.separator" ); - - private Strings() { - throw new UnsupportedOperationException(); - } - - /** - * Gives a string consisting of the given character repeated the given number of times. - * - * @param ch the character to repeat - * @param count how many times to repeat the character - * @return the resultant string - */ - public static String repeat( char ch, int count ) { - StringBuilder buffer = new StringBuilder(); - - for ( int i = 0; i < count; ++i ) - buffer.append( ch ); - - return buffer.toString(); - } - - /** - * Tells whether the given string is either {@code} or consists solely of whitespace characters. - * - * @param target string to check - * @return {@code true} if the target string is null or empty - */ - public static boolean isNullOrEmpty( String target ) { - return target == null || target.isEmpty(); - } - - - /** - * Gives a string consisting of a given string prepended and appended with surrounding characters. - * - * @param target a string - * @param begin character to prepend - * @param end character to append - * @return the surrounded string - */ - public static String surround( String target, char begin, char end ) { - return begin + target + end; - } - - /** - * Gives a string consisting of the elements of a given array of strings, each separated by a given separator - * string. - * - * @param pieces the strings to join - * @param separator the separator - * @return the joined string - */ - public static String join( String[] pieces, String separator ) { - return join( asList( pieces ), separator ); - } - - /** - * Gives a string consisting of the string representations of the elements of a given array of objects, - * each separated by a given separator string. - * - * @param pieces the elements whose string representations are to be joined - * @param separator the separator - * @return the joined string - */ - public static String join( Iterable pieces, String separator ) { - StringBuilder buffer = new StringBuilder(); - - for ( Iterator iter = pieces.iterator(); iter.hasNext(); ) { - buffer.append( iter.next() ); - - if ( iter.hasNext() ) - buffer.append( separator ); - } - - return buffer.toString(); - } -} diff --git a/third_party/java/jopt-simple/src/main/java/joptsimple/util/DateConverter.java b/third_party/java/jopt-simple/src/main/java/joptsimple/util/DateConverter.java deleted file mode 100644 index c3182ae2fd..0000000000 --- a/third_party/java/jopt-simple/src/main/java/joptsimple/util/DateConverter.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple.util; - -import java.text.DateFormat; -import java.text.ParsePosition; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Locale; - -import joptsimple.ValueConversionException; -import joptsimple.ValueConverter; -import joptsimple.internal.Messages; - -/** - * Converts values to {@link Date}s using a {@link DateFormat} object. - * - * @author Paul Holser - */ -public class DateConverter implements ValueConverter { - private final DateFormat formatter; - - /** - * Creates a converter that uses the given date formatter/parser. - * - * @param formatter the formatter/parser to use - * @throws NullPointerException if {@code formatter} is {@code null} - */ - public DateConverter( DateFormat formatter ) { - if ( formatter == null ) - throw new NullPointerException( "illegal null formatter" ); - - this.formatter = formatter; - } - - /** - * Creates a converter that uses a {@link SimpleDateFormat} with the given date/time pattern. The date formatter - * created is not {@link SimpleDateFormat#setLenient(boolean) lenient}. - * - * @param pattern expected date/time pattern - * @return the new converter - * @throws NullPointerException if {@code pattern} is {@code null} - * @throws IllegalArgumentException if {@code pattern} is invalid - */ - public static DateConverter datePattern( String pattern ) { - SimpleDateFormat formatter = new SimpleDateFormat( pattern ); - formatter.setLenient( false ); - - return new DateConverter( formatter ); - } - - public Date convert( String value ) { - ParsePosition position = new ParsePosition( 0 ); - - Date date = formatter.parse( value, position ); - if ( position.getIndex() != value.length() ) - throw new ValueConversionException( message( value ) ); - - return date; - } - - public Class valueType() { - return Date.class; - } - - public String valuePattern() { - return formatter instanceof SimpleDateFormat - ? ( (SimpleDateFormat) formatter ).toPattern() - : ""; - } - - private String message( String value ) { - String key; - Object[] arguments; - - if ( formatter instanceof SimpleDateFormat ) { - key = "with.pattern.message"; - arguments = new Object[] { value, ( (SimpleDateFormat) formatter ).toPattern() }; - } else { - key = "without.pattern.message"; - arguments = new Object[] { value }; - } - - return Messages.message( - Locale.getDefault(), - "joptsimple.ExceptionMessages", - DateConverter.class, - key, - arguments ); - } -} diff --git a/third_party/java/jopt-simple/src/main/java/joptsimple/util/EnumConverter.java b/third_party/java/jopt-simple/src/main/java/joptsimple/util/EnumConverter.java deleted file mode 100644 index c75b86607f..0000000000 --- a/third_party/java/jopt-simple/src/main/java/joptsimple/util/EnumConverter.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2014 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple.util; - -import java.text.MessageFormat; -import java.util.EnumSet; -import java.util.Iterator; -import java.util.ResourceBundle; - -import joptsimple.ValueConversionException; -import joptsimple.ValueConverter; - -/** - * Converts values to {@link java.lang.Enum}s. - * - * @author Christian Ohr - */ -public abstract class EnumConverter> implements ValueConverter { - private final Class clazz; - - private String delimiters = "[,]"; - - /** - * This constructor must be called by subclasses, providing the enum class as the parameter. - * - * @param clazz enum class - */ - protected EnumConverter( Class clazz ) { - this.clazz = clazz; - } - - @Override - public E convert( String value ) { - for ( E each : valueType().getEnumConstants() ) { - if ( each.name().equalsIgnoreCase( value ) ) { - return each; - } - } - - throw new ValueConversionException( message( value ) ); - } - - @Override - public Class valueType() { - return clazz; - } - - /** - * Sets the delimiters for the message string. Must be a 3-letter string, - * where the first character is the prefix, the second character is the - * delimiter between the values, and the 3rd character is the suffix. - * - * @param delimiters delimiters for message string. Default is [,] - */ - public void setDelimiters( String delimiters ) { - this.delimiters = delimiters; - } - - @Override - public String valuePattern() { - EnumSet values = EnumSet.allOf( valueType() ); - - StringBuilder builder = new StringBuilder(); - builder.append( delimiters.charAt(0) ); - for ( Iterator i = values.iterator(); i.hasNext(); ) { - builder.append( i.next().toString() ); - if ( i.hasNext() ) - builder.append( delimiters.charAt( 1 ) ); - } - builder.append( delimiters.charAt( 2 ) ); - - return builder.toString(); - } - - private String message( String value ) { - ResourceBundle bundle = ResourceBundle.getBundle( "joptsimple.ExceptionMessages" ); - Object[] arguments = new Object[] { value, valuePattern() }; - String template = bundle.getString( EnumConverter.class.getName() + ".message" ); - return new MessageFormat( template ).format( arguments ); - } -} diff --git a/third_party/java/jopt-simple/src/main/java/joptsimple/util/InetAddressConverter.java b/third_party/java/jopt-simple/src/main/java/joptsimple/util/InetAddressConverter.java deleted file mode 100644 index 2f116f810d..0000000000 --- a/third_party/java/jopt-simple/src/main/java/joptsimple/util/InetAddressConverter.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple.util; - -import java.net.InetAddress; -import java.net.UnknownHostException; -import java.util.Locale; - -import joptsimple.ValueConversionException; -import joptsimple.ValueConverter; -import joptsimple.internal.Messages; - -/** - * Converts values to {@link java.net.InetAddress} using {@link InetAddress#getByName(String) getByName}. - * - * @author Raymund F\u00FCl\u00F6p - */ -public class InetAddressConverter implements ValueConverter { - public InetAddress convert( String value ) { - try { - return InetAddress.getByName( value ); - } - catch ( UnknownHostException e ) { - throw new ValueConversionException( message( value ) ); - } - } - - public Class valueType() { - return InetAddress.class; - } - - public String valuePattern() { - return null; - } - - private String message( String value ) { - return Messages.message( - Locale.getDefault(), - "joptsimple.ExceptionMessages", - InetAddressConverter.class, - "message", - value ); - } -} diff --git a/third_party/java/jopt-simple/src/main/java/joptsimple/util/KeyValuePair.java b/third_party/java/jopt-simple/src/main/java/joptsimple/util/KeyValuePair.java deleted file mode 100644 index bdc2424190..0000000000 --- a/third_party/java/jopt-simple/src/main/java/joptsimple/util/KeyValuePair.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple.util; - -import static joptsimple.internal.Strings.*; - -/** - *

A simple string key/string value pair.

- * - *

This is useful as an argument type for options whose values take on the form {@code key=value}, such as JVM - * command line system properties.

- * - * @author Paul Holser - */ -public final class KeyValuePair { - public final String key; - public final String value; - - private KeyValuePair( String key, String value ) { - this.key = key; - this.value = value; - } - - /** - * Parses a string assumed to be of the form {@code key=value} into its parts. - * - * @param asString key-value string - * @return a key-value pair - * @throws NullPointerException if {@code stringRepresentation} is {@code null} - */ - public static KeyValuePair valueOf( String asString ) { - int equalsIndex = asString.indexOf( '=' ); - if ( equalsIndex == -1 ) - return new KeyValuePair( asString, EMPTY ); - - String aKey = asString.substring( 0, equalsIndex ); - String aValue = equalsIndex == asString.length() - 1 ? EMPTY : asString.substring( equalsIndex + 1 ); - - return new KeyValuePair( aKey, aValue ); - } - - @Override - public boolean equals( Object that ) { - if ( !( that instanceof KeyValuePair ) ) - return false; - - KeyValuePair other = (KeyValuePair) that; - return key.equals( other.key ) && value.equals( other.value ); - } - - @Override - public int hashCode() { - return key.hashCode() ^ value.hashCode(); - } - - @Override - public String toString() { - return key + '=' + value; - } -} diff --git a/third_party/java/jopt-simple/src/main/java/joptsimple/util/PathConverter.java b/third_party/java/jopt-simple/src/main/java/joptsimple/util/PathConverter.java deleted file mode 100644 index 295bc00362..0000000000 --- a/third_party/java/jopt-simple/src/main/java/joptsimple/util/PathConverter.java +++ /dev/null @@ -1,51 +0,0 @@ -package joptsimple.util; - -import java.nio.file.Path; -import java.nio.file.Paths; -import java.text.MessageFormat; -import java.util.ResourceBundle; - -import joptsimple.ValueConversionException; -import joptsimple.ValueConverter; - -/** - * Converts command line options to {@link Path} objects and checks the status of the underlying file. - */ -public class PathConverter implements ValueConverter { - private final PathProperties[] pathProperties; - - public PathConverter( PathProperties... pathProperties ) { - this.pathProperties = pathProperties; - } - - @Override - public Path convert( String value ) { - Path path = Paths.get(value); - - if ( pathProperties != null ) { - for ( PathProperties each : pathProperties ) { - if ( !each.accept( path ) ) - throw new ValueConversionException( message( each.getMessageKey(), path.toString() ) ); - } - } - - return path; - } - - @Override - public Class valueType() { - return Path.class; - } - - @Override - public String valuePattern() { - return null; - } - - private String message( String errorKey, String value ) { - ResourceBundle bundle = ResourceBundle.getBundle( "joptsimple.ExceptionMessages" ); - Object[] arguments = new Object[] { value, valuePattern() }; - String template = bundle.getString( PathConverter.class.getName() + "." + errorKey + ".message" ); - return new MessageFormat( template ).format( arguments ); - } -} diff --git a/third_party/java/jopt-simple/src/main/java/joptsimple/util/PathProperties.java b/third_party/java/jopt-simple/src/main/java/joptsimple/util/PathProperties.java deleted file mode 100644 index a7fb045025..0000000000 --- a/third_party/java/jopt-simple/src/main/java/joptsimple/util/PathProperties.java +++ /dev/null @@ -1,60 +0,0 @@ -package joptsimple.util; - -import java.nio.file.Files; -import java.nio.file.Path; - -/** - * Enum for checking common conditions of files and directories. - * - * @see joptsimple.util.PathConverter - */ -public enum PathProperties { - FILE_EXISTING( "file.existing" ) { - @Override - boolean accept( Path path ) { - return Files.isRegularFile( path ); - } - }, - DIRECTORY_EXISTING( "directory.existing" ) { - @Override - boolean accept( Path path ) { - return Files.isDirectory( path ); - } - }, - NOT_EXISTING( "file.not.existing" ) { - @Override - boolean accept( Path path ) { - return Files.notExists( path ); - } - }, - FILE_OVERWRITABLE( "file.overwritable" ) { - @Override - boolean accept( Path path ) { - return FILE_EXISTING.accept( path ) && WRITABLE.accept( path ); - } - }, - READABLE( "file.readable" ) { - @Override - boolean accept( Path path ) { - return Files.isReadable( path ); - } - }, - WRITABLE( "file.writable" ) { - @Override - boolean accept( Path path ) { - return Files.isWritable( path ); - } - }; - - private final String messageKey; - - private PathProperties( String messageKey ) { - this.messageKey = messageKey; - } - - abstract boolean accept( Path path ); - - String getMessageKey() { - return messageKey; - } -} diff --git a/third_party/java/jopt-simple/src/main/java/joptsimple/util/RegexMatcher.java b/third_party/java/jopt-simple/src/main/java/joptsimple/util/RegexMatcher.java deleted file mode 100644 index aca788c7ec..0000000000 --- a/third_party/java/jopt-simple/src/main/java/joptsimple/util/RegexMatcher.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - The MIT License - - Copyright (c) 2004-2015 Paul R. Holser, Jr. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -package joptsimple.util; - -import java.util.Locale; -import java.util.regex.Pattern; - -import static java.util.regex.Pattern.*; -import static joptsimple.internal.Messages.message; - -import joptsimple.ValueConversionException; -import joptsimple.ValueConverter; - -/** - * Ensures that values entirely match a regular expression. - * - * @author Paul Holser - */ -public class RegexMatcher implements ValueConverter { - private final Pattern pattern; - - /** - * Creates a matcher that uses the given regular expression, modified by the given flags. - * - * @param pattern the regular expression pattern - * @param flags modifying regex flags - * @throws IllegalArgumentException if bit values other than those corresponding to the defined match flags are - * set in {@code flags} - * @throws java.util.regex.PatternSyntaxException if the expression's syntax is invalid - */ - public RegexMatcher( String pattern, int flags ) { - this.pattern = compile( pattern, flags ); - } - - /** - * Gives a matcher that uses the given regular expression. - * - * @param pattern the regular expression pattern - * @return the new converter - * @throws java.util.regex.PatternSyntaxException if the expression's syntax is invalid - */ - public static ValueConverter regex( String pattern ) { - return new RegexMatcher( pattern, 0 ); - } - - public String convert( String value ) { - if ( !pattern.matcher( value ).matches() ) { - raiseValueConversionFailure( value ); - } - - return value; - } - - public Class valueType() { - return String.class; - } - - public String valuePattern() { - return pattern.pattern(); - } - - private void raiseValueConversionFailure( String value ) { - String message = message( - Locale.getDefault(), - "joptsimple.ExceptionMessages", - RegexMatcher.class, - "message", - value, - pattern.pattern() ); - throw new ValueConversionException( message ); - } -} diff --git a/third_party/java/jopt-simple/src/main/resources/joptsimple/ExceptionMessages.properties b/third_party/java/jopt-simple/src/main/resources/joptsimple/ExceptionMessages.properties deleted file mode 100644 index e5ce44d8c3..0000000000 --- a/third_party/java/jopt-simple/src/main/resources/joptsimple/ExceptionMessages.properties +++ /dev/null @@ -1,19 +0,0 @@ -joptsimple.IllegalOptionSpecificationException.message = {0} is not a legal option character -joptsimple.MissingRequiredOptionsException.message = Missing required option(s) {0} -joptsimple.MultipleArgumentsForOptionException.message = Found multiple arguments for option {0}, but you asked for only one -joptsimple.OptionArgumentConversionException.message = Cannot parse argument ''{0}'' of option {1} -joptsimple.OptionMissingRequiredArgumentException.message = Option {0} requires an argument -joptsimple.UnavailableOptionException.message = Option(s) {0} are unavailable given other options on the command line -joptsimple.UnconfiguredOptionException.message = Option(s) {0} not configured on this parser -joptsimple.UnrecognizedOptionException.message = {0} is not a recognized option -joptsimple.util.DateConverter.without.pattern.message = Value [{0}] does not match date/time pattern -joptsimple.util.DateConverter.with.pattern.message = Value [{0}] does not match date/time pattern [{1}] -joptsimple.util.RegexMatcher.message = Value [{0}] did not match regex [{1}] -joptsimple.util.EnumConverter.message = Value [{0}] is not one of [{1}] -joptsimple.util.PathConverter.file.existing.message = File [{0}] does not exist -joptsimple.util.PathConverter.directory.existing.message = Directory [{0}] does not exist -joptsimple.util.PathConverter.file.not.existing.message = File [{0}] does already exist -joptsimple.util.PathConverter.file.overwritable.message = File [{0}] is not overwritable -joptsimple.util.PathConverter.file.readable.message = File [{0}] is not readable -joptsimple.util.PathConverter.file.writable.message = File [{0}] is not writable -joptsimple.util.InetAddressConverter.message = Cannot convert value [{0}] into an InetAddress \ No newline at end of file diff --git a/third_party/java/jopt-simple/src/main/resources/joptsimple/HelpFormatterMessages.properties b/third_party/java/jopt-simple/src/main/resources/joptsimple/HelpFormatterMessages.properties deleted file mode 100644 index d0faea73e4..0000000000 --- a/third_party/java/jopt-simple/src/main/resources/joptsimple/HelpFormatterMessages.properties +++ /dev/null @@ -1,11 +0,0 @@ -joptsimple.BuiltinHelpFormatter.no.options.specified = No options specified -joptsimple.BuiltinHelpFormatter.non.option.arguments.header = Non-option arguments: -joptsimple.BuiltinHelpFormatter.option.header.with.required.indicator = Option (* = required) -joptsimple.BuiltinHelpFormatter.option.divider.with.required.indicator = --------------------- -joptsimple.BuiltinHelpFormatter.option.header = Option -joptsimple.BuiltinHelpFormatter.option.divider = ------ -joptsimple.BuiltinHelpFormatter.description.header = Description -joptsimple.BuiltinHelpFormatter.description.divider = ----------- -joptsimple.BuiltinHelpFormatter.default.value.header = default: -joptsimple.AlternativeLongOptionSpec.description = Alternative form of long options -joptsimple.AlternativeLongOptionSpec.arg.description = opt=value -- cgit v1.2.3