diff options
author | Thinkofdeath <thinkofdeath@spigotmc.org> | 2015-02-23 09:32:50 +0000 |
---|---|---|
committer | md_5 <git@md-5.net> | 2015-02-27 16:10:17 +1100 |
commit | 73cf0e994f963791c3e277265b7932d2d8340a18 (patch) | |
tree | b4c2e489532950f62e841411e5fdfb7e1d074d20 | |
parent | 4a50b4a372cac4e9a0c9108a79253f3fe67d894c (diff) | |
download | buildtools-73cf0e994f963791c3e277265b7932d2d8340a18.tar buildtools-73cf0e994f963791c3e277265b7932d2d8340a18.tar.gz buildtools-73cf0e994f963791c3e277265b7932d2d8340a18.tar.lz buildtools-73cf0e994f963791c3e277265b7932d2d8340a18.tar.xz buildtools-73cf0e994f963791c3e277265b7932d2d8340a18.zip |
Use JOpt for flags
-rw-r--r-- | src/main/java/org/spigotmc/builder/Builder.java | 46 |
1 files changed, 21 insertions, 25 deletions
diff --git a/src/main/java/org/spigotmc/builder/Builder.java b/src/main/java/org/spigotmc/builder/Builder.java index b7b0234..4bcec9c 100644 --- a/src/main/java/org/spigotmc/builder/Builder.java +++ b/src/main/java/org/spigotmc/builder/Builder.java @@ -45,6 +45,10 @@ import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSession; import javax.net.ssl.TrustManager; import javax.net.ssl.X509TrustManager; + +import joptsimple.OptionParser; +import joptsimple.OptionSet; +import joptsimple.OptionSpec; import lombok.RequiredArgsConstructor; import org.apache.commons.io.FileUtils; import org.apache.commons.io.output.TeeOutputStream; @@ -68,33 +72,25 @@ public class Builder public static void main(String[] args) throws Exception { - for ( String s : args ) + OptionParser parser = new OptionParser(); + OptionSpec<Void> disableCertFlag = parser.accepts( "disable-certificate-check" ); + OptionSpec<Void> dontUpdateFlag = parser.accepts( "dont-update" ); + OptionSpec<Void> skipCompileFlag = parser.accepts( "skip-compile" ); + OptionSpec<Void> generateSourceFlag = parser.accepts( "generate-source" ); + OptionSpec<Void> generateDocsFlag = parser.accepts( "generate-docs" ); + OptionSpec<Void> devFlag = parser.accepts( "dev" ); + + OptionSet options = parser.parse( args ); + + if ( options.has( disableCertFlag ) ) { - if ( "--disable-certificate-check".equals( s ) ) - { - disableHttpsCertificateCheck(); - } - if ( "--dont-update".equals( s ) ) - { - dontUpdate = true; - } - if ( "--skip-compile".endsWith( s ) ) - { - skipCompile = true; - } - if ( "--generate-source".equals( s ) ) - { - generateSource = true; - } - if ( "--generate-docs".equals( s ) ) - { - generateDocs = true; - } - if ( "--dev".equals( s ) ) - { - dev = true; - } + disableHttpsCertificateCheck(); } + dontUpdate = options.has( dontUpdateFlag ); + skipCompile = options.has( skipCompileFlag ); + generateSource = options.has( generateSourceFlag ); + generateDocs = options.has( generateDocsFlag ); + dev = options.has( devFlag ); logOutput(); |