Fix CLI command/option package tangle
Fix package tangle in CLI my extracting ExitStatus to a status package. See gh-1004
This commit is contained in:
parent
5da23e9968
commit
f95cb602cc
|
@ -19,6 +19,7 @@ package org.springframework.boot.cli.command;
|
|||
import java.util.Collection;
|
||||
|
||||
import org.springframework.boot.cli.command.options.OptionHelp;
|
||||
import org.springframework.boot.cli.command.status.ExitStatus;
|
||||
|
||||
/**
|
||||
* A single command that can be run from the CLI.
|
||||
|
@ -64,83 +65,4 @@ public interface Command {
|
|||
*/
|
||||
ExitStatus run(String... args) throws Exception;
|
||||
|
||||
/**
|
||||
* Encapsulation of the outcome of a command.
|
||||
*
|
||||
* @author Dave Syer
|
||||
*
|
||||
* @see ExitStatus#OK
|
||||
* @see ExitStatus#ERROR
|
||||
*
|
||||
*/
|
||||
public static class ExitStatus {
|
||||
/**
|
||||
* Generic "OK" exit status with zero exit code and hangup=fa;se
|
||||
*/
|
||||
public static ExitStatus OK = new ExitStatus(0, "OK");
|
||||
/**
|
||||
* Generic "not OK" exit status with non-zero exit code and hangup=true
|
||||
*/
|
||||
public static ExitStatus ERROR = new ExitStatus(-1, "ERROR", true);
|
||||
private int code;
|
||||
private String name;
|
||||
private boolean hangup;
|
||||
|
||||
/**
|
||||
* Create a new ExitStatus with an exit code and name as specified.
|
||||
*
|
||||
* @param code the exit code
|
||||
* @param name the name
|
||||
*/
|
||||
public ExitStatus(int code, String name) {
|
||||
this(code, name, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param code the exit code
|
||||
* @param name the name
|
||||
* @param hangup true if it is OK for the caller to hangup
|
||||
*/
|
||||
public ExitStatus(int code, String name, boolean hangup) {
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
this.hangup = hangup;
|
||||
}
|
||||
|
||||
/**
|
||||
* An exit code appropriate for use in System.exit()
|
||||
* @return an exit code
|
||||
*/
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
/**
|
||||
* A name describing the outcome
|
||||
* @return a name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Flag to signal that the caller can (or should) hangup. A server process with
|
||||
* non-daemon threads should set this to false.
|
||||
* @return the flag
|
||||
*/
|
||||
public boolean isHangup() {
|
||||
return hangup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the existing code to a hangup.
|
||||
*
|
||||
* @return a new ExitStatus with hangup=true
|
||||
*/
|
||||
public ExitStatus hangup() {
|
||||
return new ExitStatus(this.code, this.name, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ import java.util.Iterator;
|
|||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.boot.cli.command.Command.ExitStatus;
|
||||
import org.springframework.boot.cli.command.status.ExitStatus;
|
||||
import org.springframework.boot.cli.util.Log;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.util.Collection;
|
|||
|
||||
import org.springframework.boot.cli.command.options.OptionHandler;
|
||||
import org.springframework.boot.cli.command.options.OptionHelp;
|
||||
import org.springframework.boot.cli.command.status.ExitStatus;
|
||||
|
||||
/**
|
||||
* Base class for a {@link Command} that parse options using an {@link OptionHandler}.
|
||||
|
|
|
@ -28,6 +28,7 @@ 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.command.status.ExitStatus;
|
||||
import org.springframework.boot.cli.util.Log;
|
||||
|
||||
/**
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.springframework.boot.cli.command.AbstractCommand;
|
|||
import org.springframework.boot.cli.command.Command;
|
||||
import org.springframework.boot.cli.command.CommandRunner;
|
||||
import org.springframework.boot.cli.command.options.OptionHelp;
|
||||
import org.springframework.boot.cli.command.status.ExitStatus;
|
||||
import org.springframework.boot.cli.util.Log;
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,6 +18,7 @@ package org.springframework.boot.cli.command.core;
|
|||
|
||||
import org.springframework.boot.cli.command.AbstractCommand;
|
||||
import org.springframework.boot.cli.command.Command;
|
||||
import org.springframework.boot.cli.command.status.ExitStatus;
|
||||
import org.springframework.boot.cli.util.Log;
|
||||
|
||||
/**
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.springframework.boot.cli.command.OptionParsingCommand;
|
|||
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.command.status.ExitStatus;
|
||||
import org.springframework.boot.cli.compiler.GroovyCompiler;
|
||||
import org.springframework.boot.cli.compiler.GroovyCompilerConfiguration;
|
||||
import org.springframework.boot.cli.compiler.RepositoryConfigurationFactory;
|
||||
|
|
|
@ -47,6 +47,7 @@ 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.command.status.ExitStatus;
|
||||
import org.springframework.boot.cli.compiler.GroovyCompiler;
|
||||
import org.springframework.boot.cli.compiler.GroovyCompilerConfiguration;
|
||||
import org.springframework.boot.cli.compiler.RepositoryConfigurationFactory;
|
||||
|
|
|
@ -38,8 +38,8 @@ import joptsimple.OptionParser;
|
|||
import joptsimple.OptionSet;
|
||||
import joptsimple.OptionSpecBuilder;
|
||||
|
||||
import org.springframework.boot.cli.command.Command.ExitStatus;
|
||||
import org.springframework.boot.cli.command.OptionParsingCommand;
|
||||
import org.springframework.boot.cli.command.status.ExitStatus;
|
||||
|
||||
/**
|
||||
* Delegate used by {@link OptionParsingCommand} to parse options and run the command.
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.springframework.boot.cli.command.OptionParsingCommand;
|
|||
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.command.status.ExitStatus;
|
||||
import org.springframework.boot.cli.compiler.GroovyCompilerScope;
|
||||
import org.springframework.boot.cli.compiler.RepositoryConfigurationFactory;
|
||||
import org.springframework.boot.cli.compiler.grape.RepositoryConfiguration;
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.springframework.boot.cli.command.shell;
|
|||
import jline.console.ConsoleReader;
|
||||
|
||||
import org.springframework.boot.cli.command.AbstractCommand;
|
||||
import org.springframework.boot.cli.command.status.ExitStatus;
|
||||
|
||||
/**
|
||||
* Clear the {@link Shell} screen.
|
||||
|
|
|
@ -18,6 +18,7 @@ package org.springframework.boot.cli.command.shell;
|
|||
|
||||
import org.springframework.boot.cli.command.AbstractCommand;
|
||||
import org.springframework.boot.cli.command.Command;
|
||||
import org.springframework.boot.cli.command.status.ExitStatus;
|
||||
|
||||
/**
|
||||
* {@link Command} to quit the {@link Shell}.
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.util.List;
|
|||
|
||||
import org.springframework.boot.cli.command.Command;
|
||||
import org.springframework.boot.cli.command.options.OptionHelp;
|
||||
import org.springframework.boot.cli.command.status.ExitStatus;
|
||||
import org.springframework.boot.loader.tools.JavaExecutable;
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,6 +18,7 @@ package org.springframework.boot.cli.command.shell;
|
|||
|
||||
import org.springframework.boot.cli.command.AbstractCommand;
|
||||
import org.springframework.boot.cli.command.Command;
|
||||
import org.springframework.boot.cli.command.status.ExitStatus;
|
||||
|
||||
/**
|
||||
* {@link Command} to change the {@link Shell} prompt.
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.util.Collection;
|
|||
|
||||
import org.springframework.boot.cli.command.AbstractCommand;
|
||||
import org.springframework.boot.cli.command.Command;
|
||||
import org.springframework.boot.cli.command.status.ExitStatus;
|
||||
import org.springframework.boot.loader.tools.RunProcess;
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,6 +18,7 @@ package org.springframework.boot.cli.command.shell;
|
|||
|
||||
import org.springframework.boot.cli.command.AbstractCommand;
|
||||
import org.springframework.boot.cli.command.Command;
|
||||
import org.springframework.boot.cli.command.status.ExitStatus;
|
||||
|
||||
/**
|
||||
* {@link Command} to start a nested REPL shell.
|
||||
|
|
|
@ -0,0 +1,100 @@
|
|||
/*
|
||||
* Copyright 2012-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.cli.command.status;
|
||||
|
||||
/**
|
||||
* Encapsulation of the outcome of a command.
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @see ExitStatus#OK
|
||||
* @see ExitStatus#ERROR
|
||||
*
|
||||
*/
|
||||
public final class ExitStatus {
|
||||
|
||||
/**
|
||||
* Generic "OK" exit status with zero exit code and hangup=fa;se
|
||||
*/
|
||||
public static ExitStatus OK = new ExitStatus(0, "OK");
|
||||
|
||||
/**
|
||||
* Generic "not OK" exit status with non-zero exit code and hangup=true
|
||||
*/
|
||||
public static ExitStatus ERROR = new ExitStatus(-1, "ERROR", true);
|
||||
|
||||
private final int code;
|
||||
|
||||
private final String name;
|
||||
|
||||
private final boolean hangup;
|
||||
|
||||
/**
|
||||
* Create a new ExitStatus with an exit code and name as specified.
|
||||
*
|
||||
* @param code the exit code
|
||||
* @param name the name
|
||||
*/
|
||||
public ExitStatus(int code, String name) {
|
||||
this(code, name, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param code the exit code
|
||||
* @param name the name
|
||||
* @param hangup true if it is OK for the caller to hangup
|
||||
*/
|
||||
public ExitStatus(int code, String name, boolean hangup) {
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
this.hangup = hangup;
|
||||
}
|
||||
|
||||
/**
|
||||
* An exit code appropriate for use in System.exit()
|
||||
* @return an exit code
|
||||
*/
|
||||
public int getCode() {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
/**
|
||||
* A name describing the outcome
|
||||
* @return a name
|
||||
*/
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Flag to signal that the caller can (or should) hangup. A server process with
|
||||
* non-daemon threads should set this to false.
|
||||
* @return the flag
|
||||
*/
|
||||
public boolean isHangup() {
|
||||
return this.hangup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the existing code to a hangup.
|
||||
*
|
||||
* @return a new ExitStatus with hangup=true
|
||||
*/
|
||||
public ExitStatus hangup() {
|
||||
return new ExitStatus(this.code, this.name, true);
|
||||
}
|
||||
|
||||
}
|
|
@ -23,6 +23,7 @@ import org.springframework.boot.cli.command.OptionParsingCommand;
|
|||
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.command.status.ExitStatus;
|
||||
|
||||
/**
|
||||
* {@link Command} to run a groovy test script or scripts.
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package cli.command;
|
||||
|
||||
import org.springframework.boot.cli.command.AbstractCommand;
|
||||
import org.springframework.boot.cli.command.status.ExitStatus;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
|
|
Loading…
Reference in New Issue