Adding argument state back in after merge.
@@ -53,11 +53,12 @@ import com.blackducksoftware.integration.hub.bdio.model.externalid.ExternalIdFac
import com.blackducksoftware.integration.hub.detect.exception.DetectUserFriendlyException;
import com.blackducksoftware.integration.hub.detect.exitcode.ExitCodeReporter;
import com.blackducksoftware.integration.hub.detect.exitcode.ExitCodeType;
+import com.blackducksoftware.integration.hub.detect.help.ArgumentState;
import com.blackducksoftware.integration.hub.detect.help.DetectOption;
import com.blackducksoftware.integration.hub.detect.help.DetectOptionManager;
+import com.blackducksoftware.integration.hub.detect.help.html.HelpHtmlWriter;
import com.blackducksoftware.integration.hub.detect.help.print.DetectConfigurationPrinter;
import com.blackducksoftware.integration.hub.detect.help.print.DetectInfoPrinter;
-import com.blackducksoftware.integration.hub.detect.help.print.HelpHtmlWriter;
import com.blackducksoftware.integration.hub.detect.help.print.HelpPrinter;
import com.blackducksoftware.integration.hub.detect.hub.HubManager;
import com.blackducksoftware.integration.hub.detect.hub.HubServiceWrapper;
@@ -138,29 +139,21 @@ public class Application implements ApplicationRunner {
detectOptionManager.init();
final List<DetectOption> options = detectOptionManager.getDetectOptions();
- boolean isPrintHelp = false;
- boolean isPrintHelpDoc = false;
- boolean isInteractive = false;
- for (final String arg : applicationArguments.getSourceArgs()) {
- if (arg.equals("-h") || arg.equals("--help")) {
- isPrintHelp = true;
- } else if (arg.equals("-hdoc") || arg.equals("--helpdocument")) {
- isPrintHelpDoc = true;
- } else if (arg.equals("-i") || arg.equals("--interactive")) {
- isInteractive = true;
- }
- }
- if (isPrintHelp) {
- helpPrinter.printHelpMessage(System.out, options);
+
+ final String[] applicationArgs = applicationArguments.getSourceArgs();
+ final ArgumentState argumentState = new ArgumentState(applicationArgs);
+
+ if (argumentState.isHelp) {
+ helpPrinter.printAppropriateHelpMessage(System.out, options, argumentState);
return;
}
- if (isPrintHelpDoc) {
+ if (argumentState.isHelpDocument) {
helpHtmlWriter.writeHelpMessage(String.format("hub-detect-%s-help.html", detectInfo.getDetectVersion()));
return;
}
- if (isInteractive) {
+ if (argumentState.isInteractive) {
final InteractiveReader interactiveReader = createInteractiveReader();
final PrintStream interactivePrintStream = new PrintStream(System.out);
interactiveManager.interact(interactiveReader, interactivePrintStream);
