001/* 002 * Copyright 2012-2017 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.boot.cli.command.options; 018 019import java.util.Arrays; 020 021import joptsimple.OptionSpec; 022 023/** 024 * An {@link OptionHandler} for commands that result in the compilation of one or more 025 * Groovy scripts. 026 * 027 * @author Andy Wilkinson 028 * @author Dave Syer 029 */ 030public class CompilerOptionHandler extends OptionHandler { 031 032 private OptionSpec<Void> noGuessImportsOption; 033 034 private OptionSpec<Void> noGuessDependenciesOption; 035 036 private OptionSpec<Boolean> autoconfigureOption; 037 038 private OptionSpec<String> classpathOption; 039 040 @Override 041 protected final void options() { 042 this.noGuessImportsOption = option("no-guess-imports", 043 "Do not attempt to guess imports"); 044 this.noGuessDependenciesOption = option("no-guess-dependencies", 045 "Do not attempt to guess dependencies"); 046 this.autoconfigureOption = option("autoconfigure", 047 "Add autoconfigure compiler transformations").withOptionalArg() 048 .ofType(Boolean.class).defaultsTo(true); 049 this.classpathOption = option(Arrays.asList("classpath", "cp"), 050 "Additional classpath entries").withRequiredArg(); 051 doOptions(); 052 } 053 054 protected void doOptions() { 055 } 056 057 public OptionSpec<Void> getNoGuessImportsOption() { 058 return this.noGuessImportsOption; 059 } 060 061 public OptionSpec<Void> getNoGuessDependenciesOption() { 062 return this.noGuessDependenciesOption; 063 } 064 065 public OptionSpec<String> getClasspathOption() { 066 return this.classpathOption; 067 } 068 069 public OptionSpec<Boolean> getAutoconfigureOption() { 070 return this.autoconfigureOption; 071 } 072 073}