mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-09-03 04:26:12 +08:00
Merge pull request #4411 from joshiste/cli-improvements2
* pr/4411: Update copyright header Remove closure-execution from OptionHandler
This commit is contained in:
commit
9065ddd857
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2014 the original author or authors.
|
||||
* Copyright 2012-2016 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.
|
||||
@ -29,7 +29,6 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import groovy.lang.Closure;
|
||||
import joptsimple.BuiltinHelpFormatter;
|
||||
import joptsimple.HelpFormatter;
|
||||
import joptsimple.OptionDescriptor;
|
||||
@ -51,8 +50,6 @@ public class OptionHandler {
|
||||
|
||||
private OptionParser parser;
|
||||
|
||||
private Closure<?> closure;
|
||||
|
||||
private String help;
|
||||
|
||||
private Collection<OptionHelp> optionHelp;
|
||||
@ -76,10 +73,6 @@ public class OptionHandler {
|
||||
protected void options() {
|
||||
}
|
||||
|
||||
public void setClosure(Closure<?> closure) {
|
||||
this.closure = closure;
|
||||
}
|
||||
|
||||
public final ExitStatus run(String... args) throws Exception {
|
||||
String[] argsToUse = args.clone();
|
||||
for (int i = 0; i < argsToUse.length; i++) {
|
||||
@ -98,18 +91,6 @@ public class OptionHandler {
|
||||
* @throws Exception in case of errors
|
||||
*/
|
||||
protected ExitStatus run(OptionSet options) throws Exception {
|
||||
if (this.closure != null) {
|
||||
Object result = this.closure.call(options);
|
||||
if (result instanceof ExitStatus) {
|
||||
return (ExitStatus) result;
|
||||
}
|
||||
if (result instanceof Boolean) {
|
||||
return (Boolean) result ? ExitStatus.OK : ExitStatus.ERROR;
|
||||
}
|
||||
if (result instanceof Integer) {
|
||||
return new ExitStatus((Integer) result, "Finished");
|
||||
}
|
||||
}
|
||||
return ExitStatus.OK;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user