KEYCLOAK-3743 kcreg.sh without any options exists with 0
This commit is contained in:
parent
2acea2b2ee
commit
85db8ea44f
3 changed files with 14 additions and 5 deletions
|
@ -47,6 +47,10 @@ class AeshConsoleCallbackImpl extends AeshConsoleCallback {
|
||||||
else if(resultHandler != null)
|
else if(resultHandler != null)
|
||||||
resultHandler.onFailure(result);
|
resultHandler.onFailure(result);
|
||||||
|
|
||||||
|
if (result == CommandResult.FAILURE) {
|
||||||
|
// we assume the command has already output any error messages
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
console.stop();
|
console.stop();
|
||||||
|
|
||||||
|
|
|
@ -20,12 +20,12 @@ import org.jboss.aesh.cl.GroupCommandDefinition;
|
||||||
import org.jboss.aesh.console.command.CommandException;
|
import org.jboss.aesh.console.command.CommandException;
|
||||||
import org.jboss.aesh.console.command.CommandResult;
|
import org.jboss.aesh.console.command.CommandResult;
|
||||||
import org.jboss.aesh.console.command.invocation.CommandInvocation;
|
import org.jboss.aesh.console.command.invocation.CommandInvocation;
|
||||||
import org.keycloak.client.registration.cli.util.IoUtil;
|
|
||||||
|
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
|
|
||||||
import static org.keycloak.client.registration.cli.util.ConfigUtil.DEFAULT_CONFIG_FILE_STRING;
|
import static org.keycloak.client.registration.cli.util.ConfigUtil.DEFAULT_CONFIG_FILE_STRING;
|
||||||
|
import static org.keycloak.client.registration.cli.util.IoUtil.printOut;
|
||||||
import static org.keycloak.client.registration.cli.util.OsUtil.CMD;
|
import static org.keycloak.client.registration.cli.util.OsUtil.CMD;
|
||||||
import static org.keycloak.client.registration.cli.util.OsUtil.PROMPT;
|
import static org.keycloak.client.registration.cli.util.OsUtil.PROMPT;
|
||||||
|
|
||||||
|
@ -43,9 +43,14 @@ public class KcRegCmd extends AbstractGlobalOptionsCmd {
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(CommandInvocation commandInvocation) throws CommandException, InterruptedException {
|
public CommandResult execute(CommandInvocation commandInvocation) throws CommandException, InterruptedException {
|
||||||
try {
|
try {
|
||||||
IoUtil.printOut(usage());
|
// if --help was requested then status is SUCCESS
|
||||||
|
// if not we print help anyway, but status is FAILURE
|
||||||
return CommandResult.SUCCESS;
|
if (printHelp()) {
|
||||||
|
return CommandResult.SUCCESS;
|
||||||
|
} else {
|
||||||
|
printOut(usage());
|
||||||
|
return CommandResult.FAILURE;
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
commandInvocation.stop();
|
commandInvocation.stop();
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class KcRegTest extends AbstractCliTest {
|
||||||
*/
|
*/
|
||||||
KcRegExec exe = execute("");
|
KcRegExec exe = execute("");
|
||||||
|
|
||||||
Assert.assertEquals("exitCode == 0", 0, exe.exitCode());
|
Assert.assertEquals("exitCode", 1, exe.exitCode());
|
||||||
|
|
||||||
List<String> lines = exe.stdoutLines();
|
List<String> lines = exe.stdoutLines();
|
||||||
Assert.assertTrue("stdout output not empty", lines.size() > 0);
|
Assert.assertTrue("stdout output not empty", lines.size() > 0);
|
||||||
|
|
Loading…
Reference in a new issue