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