blob: 168084ec792ab6aadfdb6dbd2a260236d50d9149 [file]
package com.apigee.security.oas;
import com.beust.jcommander.ParameterException;
import com.google.common.flogger.FluentLogger;
import com.google.inject.Provider;
import java.io.PrintWriter;
import javax.inject.Inject;
/** Class that handles the execution. */
final class CommandLineBaseRunner implements CommandLineRunner {
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
private final Provider<PrintWriter> printWriterProvider;
private final CommandLineParser commandLineParser;
@Inject
CommandLineBaseRunner(
Provider<PrintWriter> printWriterProvider, CommandLineParser commandLineParser) {
this.printWriterProvider = printWriterProvider;
this.commandLineParser = commandLineParser;
}
/**
* Calls different methods for parsing & validity of arguments, OpenAPI Specification Document
* (v3), and its security features.
*
* <p>Takes a {@code File} to a OpenAPI Specification (v3) document and outputs its Security
* Validity.
*
* @param args Arguments that are passed through command line interface.
*/
@Override
public void run(String[] args) {
PrintWriter printWriter = printWriterProvider.get();
try {
commandLineParser.parseArguments(args);
} catch (ParameterException e) {
logger.atSevere().withCause(e).log("Unable to parse arguments");
printWriter.println(e.getLocalizedMessage());
} finally {
printWriter.close();
}
}
}