Commit bd6c672b authored by Phillip Webb's avatar Phillip Webb

Drop jumping into shell when running without args

Change SpringCli so that running without arguments no longer jumps into
the embedded REPL shell. This restores the ability to obtain quick usage
help by simply typing `spring` from the command prompt.

Windows users or developers that prefer the embedded shell can still
launch it using `spring shell`.
parent f56318e9
......@@ -144,12 +144,11 @@ public class SpringCli {
* @throws Exception
*/
protected void run(String... args) throws Exception {
String commandName = "shell";
if (args.length > 0) {
commandName = args[0];
if (args.length == 0) {
throw new NoArgumentsException();
}
String[] commandArguments = args.length > 1 ? Arrays.copyOfRange(args, 1,
args.length) : new String[0];
String commandName = args[0];
String[] commandArguments = Arrays.copyOfRange(args, 1, args.length);
Command command = find(commandName);
if (command == null) {
throw new NoSuchCommandException(commandName);
......
/*
* Copyright 2012-2013 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;
import java.io.IOException;
import org.springframework.boot.cli.SpringCli;
/**
* @author Dave Syer
*/
public class Shell {
public static void main(String... args) throws IOException {
if (args.length == 0) {
SpringCli.main("shell"); // right into the REPL by default
}
else {
SpringCli.main(args);
}
}
}
......@@ -26,6 +26,7 @@ import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.springframework.boot.cli.SpringCli.NoArgumentsException;
import org.springframework.boot.cli.SpringCli.NoHelpCommandArgumentsException;
import static org.hamcrest.Matchers.equalTo;
......@@ -91,8 +92,8 @@ public class SpringCliTests {
@Test
public void runWithoutArguments() throws Exception {
this.thrown.expect(NoArgumentsException.class);
this.cli.run();
verify(this.shellCommand).run();
}
@Test
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment