Fix CLI package and class tangles
This commit is contained in:
@@ -14,12 +14,14 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.cli.command;
|
||||
package org.springframework.boot.cli;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.boot.cli.command.Command;
|
||||
import org.springframework.boot.cli.command.CommandFactory;
|
||||
import org.springframework.boot.cli.command.core.VersionCommand;
|
||||
import org.springframework.boot.cli.command.grab.GrabCommand;
|
||||
import org.springframework.boot.cli.command.jar.JarCommand;
|
||||
@@ -19,7 +19,9 @@ package org.springframework.boot.cli;
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
import org.springframework.boot.cli.command.CommandFactory;
|
||||
import org.springframework.boot.cli.command.CommandRunner;
|
||||
import org.springframework.boot.cli.command.core.HelpCommand;
|
||||
import org.springframework.boot.cli.command.core.HintCommand;
|
||||
import org.springframework.boot.cli.command.core.VersionCommand;
|
||||
import org.springframework.boot.cli.command.shell.ShellCommand;
|
||||
|
||||
@@ -37,10 +39,10 @@ public class SpringCli {
|
||||
System.setProperty("java.awt.headless", Boolean.toString(true));
|
||||
|
||||
CommandRunner runner = new CommandRunner("spring");
|
||||
runner.addHelpCommand();
|
||||
runner.addCommand(new HelpCommand(runner));
|
||||
addServiceLoaderCommands(runner);
|
||||
runner.addCommand(new ShellCommand());
|
||||
runner.addHintCommand();
|
||||
runner.addCommand(new HintCommand(runner));
|
||||
runner.setOptionCommands(HelpCommand.class, VersionCommand.class);
|
||||
|
||||
int exitCode = runner.runAndHandleErrors(args);
|
||||
|
||||
@@ -19,6 +19,8 @@ package org.springframework.boot.cli.command;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.springframework.boot.cli.command.options.OptionHelp;
|
||||
|
||||
/**
|
||||
* Abstract {@link Command} implementation.
|
||||
*
|
||||
|
||||
@@ -18,6 +18,8 @@ package org.springframework.boot.cli.command;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.springframework.boot.cli.command.options.OptionHelp;
|
||||
|
||||
/**
|
||||
* A single command that can be run from the CLI.
|
||||
*
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.cli;
|
||||
package org.springframework.boot.cli.command;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.cli;
|
||||
package org.springframework.boot.cli.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -24,9 +24,7 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.boot.cli.command.Command;
|
||||
import org.springframework.boot.cli.command.core.HelpCommand;
|
||||
import org.springframework.boot.cli.command.core.HintCommand;
|
||||
import org.springframework.boot.cli.util.Log;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -64,20 +62,6 @@ public class CommandRunner implements Iterable<Command> {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add 'help' support.
|
||||
*/
|
||||
public void addHelpCommand() {
|
||||
this.commands.add(new HelpCommand(this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add 'hint' support for command line completion.
|
||||
*/
|
||||
public void addHintCommand() {
|
||||
this.commands.add(new HintCommand(this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the specified commands.
|
||||
* @param commands the commands to add
|
||||
@@ -14,7 +14,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.cli;
|
||||
package org.springframework.boot.cli.command;
|
||||
|
||||
|
||||
/**
|
||||
* Exception used to indicate that no arguemnts were specified.
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.cli;
|
||||
package org.springframework.boot.cli.command;
|
||||
|
||||
/**
|
||||
* Exception used to when the help command is called without arguments.
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.cli;
|
||||
package org.springframework.boot.cli.command;
|
||||
|
||||
/**
|
||||
* Exception used when a command is not found.
|
||||
@@ -18,6 +18,9 @@ package org.springframework.boot.cli.command;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.springframework.boot.cli.command.options.OptionHandler;
|
||||
import org.springframework.boot.cli.command.options.OptionHelp;
|
||||
|
||||
/**
|
||||
* Base class for a {@link Command} that parse options using an {@link OptionHandler}.
|
||||
*
|
||||
|
||||
@@ -22,13 +22,13 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.boot.cli.CommandRunner;
|
||||
import org.springframework.boot.cli.Log;
|
||||
import org.springframework.boot.cli.NoHelpCommandArgumentsException;
|
||||
import org.springframework.boot.cli.NoSuchCommandException;
|
||||
import org.springframework.boot.cli.command.AbstractCommand;
|
||||
import org.springframework.boot.cli.command.Command;
|
||||
import org.springframework.boot.cli.command.OptionHelp;
|
||||
import org.springframework.boot.cli.command.CommandRunner;
|
||||
import org.springframework.boot.cli.command.NoHelpCommandArgumentsException;
|
||||
import org.springframework.boot.cli.command.NoSuchCommandException;
|
||||
import org.springframework.boot.cli.command.options.OptionHelp;
|
||||
import org.springframework.boot.cli.util.Log;
|
||||
|
||||
/**
|
||||
* Internal {@link Command} used for 'help' requests.
|
||||
|
||||
@@ -20,11 +20,11 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.boot.cli.CommandRunner;
|
||||
import org.springframework.boot.cli.Log;
|
||||
import org.springframework.boot.cli.command.AbstractCommand;
|
||||
import org.springframework.boot.cli.command.Command;
|
||||
import org.springframework.boot.cli.command.OptionHelp;
|
||||
import org.springframework.boot.cli.command.CommandRunner;
|
||||
import org.springframework.boot.cli.command.options.OptionHelp;
|
||||
import org.springframework.boot.cli.util.Log;
|
||||
|
||||
/**
|
||||
* Internal {@link Command} to provide hints for shell auto-completion. Expects to be
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
|
||||
package org.springframework.boot.cli.command.core;
|
||||
|
||||
import org.springframework.boot.cli.Log;
|
||||
import org.springframework.boot.cli.command.AbstractCommand;
|
||||
import org.springframework.boot.cli.command.Command;
|
||||
import org.springframework.boot.cli.util.Log;
|
||||
|
||||
/**
|
||||
* {@link Command} to display the 'version' number.
|
||||
|
||||
@@ -21,12 +21,12 @@ import java.util.List;
|
||||
import joptsimple.OptionSet;
|
||||
|
||||
import org.springframework.boot.cli.command.Command;
|
||||
import org.springframework.boot.cli.command.CompilerOptionHandler;
|
||||
import org.springframework.boot.cli.command.OptionParsingCommand;
|
||||
import org.springframework.boot.cli.command.SourceOptions;
|
||||
import org.springframework.boot.cli.command.options.CompilerOptionHandler;
|
||||
import org.springframework.boot.cli.command.options.OptionSetGroovyCompilerConfiguration;
|
||||
import org.springframework.boot.cli.command.options.SourceOptions;
|
||||
import org.springframework.boot.cli.compiler.GroovyCompiler;
|
||||
import org.springframework.boot.cli.compiler.GroovyCompilerConfiguration;
|
||||
import org.springframework.boot.cli.compiler.GroovyCompilerConfigurationAdapter;
|
||||
import org.springframework.boot.cli.compiler.RepositoryConfigurationFactory;
|
||||
import org.springframework.boot.cli.compiler.grape.RepositoryConfiguration;
|
||||
|
||||
@@ -51,7 +51,7 @@ public class GrabCommand extends OptionParsingCommand {
|
||||
List<RepositoryConfiguration> repositoryConfiguration = RepositoryConfigurationFactory
|
||||
.createDefaultRepositoryConfiguration();
|
||||
|
||||
GroovyCompilerConfiguration configuration = new GroovyCompilerConfigurationAdapter(
|
||||
GroovyCompilerConfiguration configuration = new OptionSetGroovyCompilerConfiguration(
|
||||
options, this, repositoryConfiguration);
|
||||
|
||||
if (System.getProperty("grape.root") == null) {
|
||||
|
||||
@@ -42,13 +42,13 @@ import org.codehaus.groovy.ast.expr.ConstantExpression;
|
||||
import org.codehaus.groovy.control.SourceUnit;
|
||||
import org.codehaus.groovy.transform.ASTTransformation;
|
||||
import org.springframework.boot.cli.command.Command;
|
||||
import org.springframework.boot.cli.command.CompilerOptionHandler;
|
||||
import org.springframework.boot.cli.command.OptionParsingCommand;
|
||||
import org.springframework.boot.cli.command.SourceOptions;
|
||||
import org.springframework.boot.cli.command.jar.ResourceMatcher.MatchedResource;
|
||||
import org.springframework.boot.cli.command.options.CompilerOptionHandler;
|
||||
import org.springframework.boot.cli.command.options.OptionSetGroovyCompilerConfiguration;
|
||||
import org.springframework.boot.cli.command.options.SourceOptions;
|
||||
import org.springframework.boot.cli.compiler.GroovyCompiler;
|
||||
import org.springframework.boot.cli.compiler.GroovyCompilerConfiguration;
|
||||
import org.springframework.boot.cli.compiler.GroovyCompilerConfigurationAdapter;
|
||||
import org.springframework.boot.cli.compiler.RepositoryConfigurationFactory;
|
||||
import org.springframework.boot.cli.compiler.grape.RepositoryConfiguration;
|
||||
import org.springframework.boot.cli.jar.PackagedSpringApplicationLauncher;
|
||||
@@ -137,7 +137,7 @@ public class JarCommand extends OptionParsingCommand {
|
||||
private GroovyCompiler createCompiler(OptionSet options) {
|
||||
List<RepositoryConfiguration> repositoryConfiguration = RepositoryConfigurationFactory
|
||||
.createDefaultRepositoryConfiguration();
|
||||
GroovyCompilerConfiguration configuration = new GroovyCompilerConfigurationAdapter(
|
||||
GroovyCompilerConfiguration configuration = new OptionSetGroovyCompilerConfiguration(
|
||||
options, this, repositoryConfiguration);
|
||||
GroovyCompiler groovyCompiler = new GroovyCompiler(configuration);
|
||||
groovyCompiler.getAstTransformations().add(0, new GrabAnnotationTransform());
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.cli.command;
|
||||
package org.springframework.boot.cli.command.options;
|
||||
|
||||
import joptsimple.OptionSpec;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.cli.command;
|
||||
package org.springframework.boot.cli.command.options;
|
||||
|
||||
import groovy.lang.Closure;
|
||||
|
||||
@@ -31,6 +31,8 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.springframework.boot.cli.command.OptionParsingCommand;
|
||||
|
||||
import joptsimple.BuiltinHelpFormatter;
|
||||
import joptsimple.HelpFormatter;
|
||||
import joptsimple.OptionDescriptor;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.cli.command;
|
||||
package org.springframework.boot.cli.command.options;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@@ -14,14 +14,16 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.cli.compiler;
|
||||
package org.springframework.boot.cli.command.options;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import joptsimple.OptionSet;
|
||||
import joptsimple.OptionSpec;
|
||||
|
||||
import org.springframework.boot.cli.command.CompilerOptionHandler;
|
||||
import org.springframework.boot.cli.compiler.GroovyCompilerConfiguration;
|
||||
import org.springframework.boot.cli.compiler.GroovyCompilerScope;
|
||||
import org.springframework.boot.cli.compiler.RepositoryConfigurationFactory;
|
||||
import org.springframework.boot.cli.compiler.grape.RepositoryConfiguration;
|
||||
|
||||
/**
|
||||
@@ -30,7 +32,7 @@ import org.springframework.boot.cli.compiler.grape.RepositoryConfiguration;
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class GroovyCompilerConfigurationAdapter implements GroovyCompilerConfiguration {
|
||||
public class OptionSetGroovyCompilerConfiguration implements GroovyCompilerConfiguration {
|
||||
|
||||
private final OptionSet options;
|
||||
|
||||
@@ -38,13 +40,13 @@ public class GroovyCompilerConfigurationAdapter implements GroovyCompilerConfigu
|
||||
|
||||
private final List<RepositoryConfiguration> repositoryConfiguration;
|
||||
|
||||
protected GroovyCompilerConfigurationAdapter(OptionSet optionSet,
|
||||
protected OptionSetGroovyCompilerConfiguration(OptionSet optionSet,
|
||||
CompilerOptionHandler compilerOptionHandler) {
|
||||
this(optionSet, compilerOptionHandler, RepositoryConfigurationFactory
|
||||
.createDefaultRepositoryConfiguration());
|
||||
}
|
||||
|
||||
public GroovyCompilerConfigurationAdapter(OptionSet optionSet,
|
||||
public OptionSetGroovyCompilerConfiguration(OptionSet optionSet,
|
||||
CompilerOptionHandler compilerOptionHandler,
|
||||
List<RepositoryConfiguration> repositoryConfiguration) {
|
||||
this.options = optionSet;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.cli.command;
|
||||
package org.springframework.boot.cli.command.options;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -25,10 +25,10 @@ import joptsimple.OptionSet;
|
||||
import joptsimple.OptionSpec;
|
||||
|
||||
import org.springframework.boot.cli.command.Command;
|
||||
import org.springframework.boot.cli.command.CompilerOptionHandler;
|
||||
import org.springframework.boot.cli.command.OptionParsingCommand;
|
||||
import org.springframework.boot.cli.command.SourceOptions;
|
||||
import org.springframework.boot.cli.compiler.GroovyCompilerConfigurationAdapter;
|
||||
import org.springframework.boot.cli.command.options.CompilerOptionHandler;
|
||||
import org.springframework.boot.cli.command.options.OptionSetGroovyCompilerConfiguration;
|
||||
import org.springframework.boot.cli.command.options.SourceOptions;
|
||||
import org.springframework.boot.cli.compiler.GroovyCompilerScope;
|
||||
import org.springframework.boot.cli.compiler.RepositoryConfigurationFactory;
|
||||
import org.springframework.boot.cli.compiler.grape.RepositoryConfiguration;
|
||||
@@ -121,7 +121,7 @@ public class RunCommand extends OptionParsingCommand {
|
||||
* {@link SpringApplicationRunnerConfiguration}.
|
||||
*/
|
||||
private class SpringApplicationRunnerConfigurationAdapter extends
|
||||
GroovyCompilerConfigurationAdapter implements
|
||||
OptionSetGroovyCompilerConfiguration implements
|
||||
SpringApplicationRunnerConfiguration {
|
||||
|
||||
public SpringApplicationRunnerConfigurationAdapter(OptionSet options,
|
||||
|
||||
@@ -30,9 +30,9 @@ import jline.console.completer.Completer;
|
||||
import jline.console.completer.FileNameCompleter;
|
||||
import jline.console.completer.StringsCompleter;
|
||||
|
||||
import org.springframework.boot.cli.Log;
|
||||
import org.springframework.boot.cli.command.Command;
|
||||
import org.springframework.boot.cli.command.OptionHelp;
|
||||
import org.springframework.boot.cli.command.options.OptionHelp;
|
||||
import org.springframework.boot.cli.util.Log;
|
||||
|
||||
/**
|
||||
* JLine {@link Completer} for Spring Boot {@link Command}s.
|
||||
|
||||
@@ -22,7 +22,7 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.boot.cli.command.Command;
|
||||
import org.springframework.boot.cli.command.OptionHelp;
|
||||
import org.springframework.boot.cli.command.options.OptionHelp;
|
||||
import org.springframework.boot.cli.util.JavaExecutable;
|
||||
|
||||
/**
|
||||
|
||||
@@ -31,9 +31,10 @@ import jline.console.ConsoleReader;
|
||||
import jline.console.completer.CandidateListCompletionHandler;
|
||||
|
||||
import org.fusesource.jansi.AnsiRenderer.Code;
|
||||
import org.springframework.boot.cli.CommandRunner;
|
||||
import org.springframework.boot.cli.command.Command;
|
||||
import org.springframework.boot.cli.command.CommandFactory;
|
||||
import org.springframework.boot.cli.command.CommandRunner;
|
||||
import org.springframework.boot.cli.command.core.HelpCommand;
|
||||
import org.springframework.boot.cli.command.core.VersionCommand;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -83,7 +84,7 @@ public class Shell {
|
||||
|
||||
private ShellCommandRunner createCommandRunner() {
|
||||
ShellCommandRunner runner = new ShellCommandRunner();
|
||||
runner.addHelpCommand();
|
||||
runner.addCommand(new HelpCommand(runner));
|
||||
runner.addCommands(getCommands());
|
||||
runner.addAliases("exit", "quit");
|
||||
runner.addAliases("help", "?");
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.boot.cli.command.shell;
|
||||
|
||||
import org.springframework.boot.cli.CommandException;
|
||||
import org.springframework.boot.cli.command.CommandException;
|
||||
|
||||
/**
|
||||
* Exception used to stop the {@link Shell}.
|
||||
|
||||
@@ -19,10 +19,10 @@ package org.springframework.boot.cli.command.test;
|
||||
import joptsimple.OptionSet;
|
||||
|
||||
import org.springframework.boot.cli.command.Command;
|
||||
import org.springframework.boot.cli.command.CompilerOptionHandler;
|
||||
import org.springframework.boot.cli.command.OptionParsingCommand;
|
||||
import org.springframework.boot.cli.command.SourceOptions;
|
||||
import org.springframework.boot.cli.compiler.GroovyCompilerConfigurationAdapter;
|
||||
import org.springframework.boot.cli.command.options.CompilerOptionHandler;
|
||||
import org.springframework.boot.cli.command.options.OptionSetGroovyCompilerConfiguration;
|
||||
import org.springframework.boot.cli.command.options.SourceOptions;
|
||||
|
||||
/**
|
||||
* {@link Command} to run a groovy test script or scripts.
|
||||
@@ -60,7 +60,7 @@ public class TestCommand extends OptionParsingCommand {
|
||||
* {@link TestRunnerConfiguration}.
|
||||
*/
|
||||
private class TestRunnerConfigurationAdapter extends
|
||||
GroovyCompilerConfigurationAdapter implements TestRunnerConfiguration {
|
||||
OptionSetGroovyCompilerConfiguration implements TestRunnerConfiguration {
|
||||
|
||||
public TestRunnerConfigurationAdapter(OptionSet options,
|
||||
CompilerOptionHandler optionHandler) {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.cli;
|
||||
package org.springframework.boot.cli.util;
|
||||
|
||||
/**
|
||||
* Simple logger used by the CLI.
|
||||
Reference in New Issue
Block a user