Java Code Examples for com.martiansoftware.jsap.JSAPResult#getStringArray()
The following examples show how to use
com.martiansoftware.jsap.JSAPResult#getStringArray() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Main.java From nopol with GNU General Public License v2.0 | 5 votes |
private boolean parseArguments(String[] args) { JSAPResult jsapConfig = jsap.parse(args); if (!jsapConfig.success()) { System.err.println(); for (Iterator<?> errs = jsapConfig.getErrorMessageIterator(); errs.hasNext(); ) { System.err.println("Error: " + errs.next()); } showUsage(); return false; } String[] sources = jsapConfig.getStringArray("source"); final File[] sourceFiles = new File[sources.length]; for (int i = 0; i < sources.length; i++) { String path = sources[i]; File sourceFile = FileLibrary.openFrom(path); sourceFiles[i] = sourceFile; } final URL[] classpath = JavaLibrary.classpathFrom(jsapConfig.getString("classpath")); this.nopolContext = new NopolContext(sourceFiles, classpath, jsapConfig.getStringArray("test")); nopolContext.setType(strToStatementType(jsapConfig.getString("type"))); nopolContext.setMode(strToMode(jsapConfig.getString("mode"))); nopolContext.setSynthesis(strToSynthesis(jsapConfig.getString("synthesis"))); nopolContext.setOracle(strToOracle(jsapConfig.getString("oracle"))); nopolContext.setSolver(strToSolver(jsapConfig.getString("solver"))); if (jsapConfig.getString("solverPath") != null) { nopolContext.setSolverPath(jsapConfig.getString("solverPath")); SolverFactory.setSolver(nopolContext.getSolver(), nopolContext.getSolverPath()); } nopolContext.setComplianceLevel(jsapConfig.getInt("complianceLevel", nopolContext.getComplianceLevel())); nopolContext.setMaxTimeInMinutes(jsapConfig.getInt("maxTime", nopolContext.getMaxTimeInMinutes())); nopolContext.setMaxTimeEachTypeOfFixInMinutes(jsapConfig.getLong("maxTimeType",nopolContext.getMaxTimeEachTypeOfFixInMinutes())); nopolContext.setLocalizer(strToLocalizer(jsapConfig.getString("faultLocalization"))); nopolContext.setOutputFolder(jsapConfig.getString("outputFolder")); nopolContext.setJson(jsapConfig.getBoolean("outputJson", false)); return true; }
Example 2
Source File: ParallelFilteredProcessorRunner.java From BUbiNG with Apache License 2.0 | 4 votes |
public static void main(final String[] arg) throws Exception { final SimpleJSAP jsap = new SimpleJSAP(ParallelFilteredProcessorRunner.class.getName(), "Processes a store.", new Parameter[] { new FlaggedOption("filter", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 'f', "filter", "A WarcRecord filter that recods must pass in order to be processed."), new FlaggedOption("processor", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 'p', "processor", "A processor to be applied to data.").setAllowMultipleDeclarations(true), new FlaggedOption("writer", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 'w', "writer", "A writer to be applied to the results.").setAllowMultipleDeclarations(true), new FlaggedOption("output", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 'o', "output", "The output filename (- for stdout).").setAllowMultipleDeclarations(true), new FlaggedOption("threads", JSAP.INTSIZE_PARSER, Integer.toString(Runtime.getRuntime().availableProcessors()), JSAP.NOT_REQUIRED, 'T', "threads", "The number of threads to be used."), new Switch("sequential", 'S', "sequential"), new UnflaggedOption("store", JSAP.STRING_PARSER, JSAP.NOT_REQUIRED, "The name of the store (if omitted, stdin)."), }); final JSAPResult jsapResult = jsap.parse(arg); if (jsap.messagePrinted()) return; final String filterSpec = jsapResult.getString("filter"); final Filter<WarcRecord> filter; if (filterSpec != null) { final FilterParser<WarcRecord> parser = new FilterParser<>(WarcRecord.class); filter = parser.parse(filterSpec); } else filter = null; final InputStream in = jsapResult.userSpecified("store") ? new FastBufferedInputStream(new FileInputStream(jsapResult.getString("store"))) : System.in; final ParallelFilteredProcessorRunner parallelFilteredProcessorRunner = new ParallelFilteredProcessorRunner(in, filter); final String[] processor = jsapResult.getStringArray("processor"); final String[] writer = jsapResult.getStringArray("writer"); final String[] output = jsapResult.getStringArray("output"); if (processor.length != writer.length) throw new IllegalArgumentException("You must specify the same number or processors and writers"); if (output.length != writer.length) throw new IllegalArgumentException("You must specify the same number or output specifications and writers"); final String[] packages = new String[] { ParallelFilteredProcessorRunner.class.getPackage().getName() }; final PrintStream[] ops = new PrintStream[processor.length]; for (int i = 0; i < processor.length; i++) { ops[i] = "-".equals(output[i]) ? System.out : new PrintStream(new FastBufferedOutputStream(new FileOutputStream(output[i])), false, "UTF-8"); // TODO: these casts to SOMETHING<Object> are necessary for compilation under Eclipse. Check in the future. parallelFilteredProcessorRunner.add((Processor<Object>)ObjectParser.fromSpec(processor[i], Processor.class, packages, new String[] { "getInstance" }), (Writer<Object>)ObjectParser.fromSpec(writer[i], Writer.class, packages, new String[] { "getInstance" }), ops[i]); } if (jsapResult.userSpecified("sequential")) parallelFilteredProcessorRunner.runSequentially(); else parallelFilteredProcessorRunner.run(jsapResult.getInt("threads")); for (int i = 0; i < processor.length; i++) ops[i].close(); }
Example 3
Source File: GitRepositoryLauncher.java From repairnator with MIT License | 4 votes |
@Override protected void initConfig(JSAPResult arguments) { if (LauncherUtils.getArgDebug(arguments)) { getConfig().setDebug(true); } getConfig().setClean(true); getConfig().setRunId(LauncherUtils.getArgRunId(arguments)); getConfig().setGithubToken(LauncherUtils.getArgGithubOAuth(arguments)); if (GitRepositoryLauncherUtils.getArgGitRepositoryMode(arguments)) { getConfig().setLauncherMode(LauncherMode.GIT_REPOSITORY); if (GitRepositoryLauncherUtils.getArgGitRepositoryFirstCommit(arguments)) { getConfig().setGitRepositoryFirstCommit(true); } } else { System.err.println("Error: Parameter 'gitrepo' is required in GIT_REPOSITORY launcher mode."); LauncherUtils.printUsage(jsap, LauncherType.PIPELINE); } if (LauncherUtils.getArgOutput(arguments) != null) { getConfig().setOutputPath(LauncherUtils.getArgOutput(arguments).getPath()); } getConfig().setMongodbHost(LauncherUtils.getArgMongoDBHost(arguments)); getConfig().setMongodbName(LauncherUtils.getArgMongoDBName(arguments)); getConfig().setSmtpServer(LauncherUtils.getArgSmtpServer(arguments)); getConfig().setSmtpPort(LauncherUtils.getArgSmtpPort(arguments)); getConfig().setSmtpTLS(LauncherUtils.getArgSmtpTLS(arguments)); getConfig().setSmtpUsername(LauncherUtils.getArgSmtpUsername(arguments)); getConfig().setSmtpPassword(LauncherUtils.getArgSmtpPassword(arguments)); getConfig().setNotifyTo(LauncherUtils.getArgNotifyto(arguments)); if (LauncherUtils.getArgPushUrl(arguments) != null) { getConfig().setPush(true); getConfig().setPushRemoteRepo(LauncherUtils.getArgPushUrl(arguments)); } getConfig().setCreatePR(LauncherUtils.getArgCreatePR(arguments)); // we fork if we need to create a PR or if we need to notify if (getConfig().isCreatePR() || (getConfig().getSmtpServer() != null && !getConfig().getSmtpServer().isEmpty() && getConfig().getNotifyTo() != null && getConfig().getNotifyTo().length > 0)) { getConfig().setFork(true); } if (arguments.getString("gitRepositoryUrl") == null) { System.err.println("Error: Parameter 'gitrepourl' is required in GIT_REPOSITORY launcher mode."); LauncherUtils.printUsage(jsap, LauncherType.PIPELINE); } if (getConfig().isGitRepositoryFirstCommit() && arguments.getString("gitRepositoryIdCommit") != null) { System.err.println("Error: Parameters 'gitrepofirstcommit' and 'gitrepoidcommit' cannot be used at the same time."); LauncherUtils.printUsage(jsap, LauncherType.PIPELINE); } getConfig().setGitRepositoryUrl(arguments.getString("gitRepositoryUrl")); getConfig().setGitRepositoryBranch(arguments.getString("gitRepositoryBranch")); getConfig().setGitRepositoryIdCommit(arguments.getString("gitRepositoryIdCommit")); getConfig().setZ3solverPath(new File(arguments.getString("z3")).getPath()); getConfig().setWorkspacePath(arguments.getString("workspace")); if (arguments.getBoolean("tmpDirAsWorkSpace")) { tempDir = com.google.common.io.Files.createTempDir(); getConfig().setWorkspacePath(tempDir.getAbsolutePath()); getConfig().setOutputPath(tempDir.getAbsolutePath()); getConfig().setZ3solverPath(new File(tempDir.getAbsolutePath() + File.separator + "z3_for_linux").getPath()); } getConfig().setGithubUserEmail(LauncherUtils.getArgGithubUserEmail(arguments)); getConfig().setGithubUserName(LauncherUtils.getArgGithubUserName(arguments)); getConfig().setListenerMode(arguments.getString("listenermode")); getConfig().setActiveMQUrl(arguments.getString("activemqurl")); getConfig().setActiveMQListenQueueName(arguments.getString("activemqlistenqueuename")); getConfig().setGitUrl(arguments.getString("giturl")); getConfig().setGitBranch(arguments.getString("gitbranch")); getConfig().setGitCommitHash(arguments.getString("gitcommithash")); getConfig().setMavenHome(arguments.getString("MavenHome")); if (arguments.getFile("projectsToIgnore") != null) { getConfig().setProjectsToIgnoreFilePath(arguments.getFile("projectsToIgnore").getPath()); } getConfig().setRepairTools(new HashSet<>(Arrays.asList(arguments.getStringArray("repairTools")))); // Make sure that it is a multiple of three in the list if((arguments.getStringArray("experimentalPluginRepoList").length) % 3 == 0) { getConfig().setExperimentalPluginRepoList(arguments.getStringArray("experimentalPluginRepoList")); } else if (arguments.getStringArray("experimentalPluginRepoList").length != 0) { LOGGER.warn("The experimental plugin repo list is not correctly formed." + " Please make sure you have provided id, name and url for all repos. " + "Repairnator will continue without these repos."); getConfig().setExperimentalPluginRepoList(null); } else { getConfig().setExperimentalPluginRepoList(null); } }
Example 4
Source File: LegacyLauncher.java From repairnator with MIT License | 4 votes |
protected void initConfig(JSAPResult arguments) { if (LauncherUtils.getArgDebug(arguments)) { this.getConfig().setDebug(true); } this.getConfig().setClean(true); this.getConfig().setRunId(LauncherUtils.getArgRunId(arguments)); this.getConfig().setGithubToken(LauncherUtils.getArgGithubOAuth(arguments)); if (LauncherUtils.gerArgBearsMode(arguments)) { this.getConfig().setLauncherMode(LauncherMode.BEARS); } else if (LauncherUtils.gerArgCheckstyleMode(arguments)) { this.getConfig().setLauncherMode(LauncherMode.CHECKSTYLE); } else { this.getConfig().setLauncherMode(LauncherMode.REPAIR); } if (LauncherUtils.getArgOutput(arguments) != null) { this.getConfig().setOutputPath(LauncherUtils.getArgOutput(arguments).getPath()); } this.getConfig().setMongodbHost(LauncherUtils.getArgMongoDBHost(arguments)); this.getConfig().setMongodbName(LauncherUtils.getArgMongoDBName(arguments)); this.getConfig().setSmtpServer(LauncherUtils.getArgSmtpServer(arguments)); this.getConfig().setSmtpPort(LauncherUtils.getArgSmtpPort(arguments)); this.getConfig().setSmtpTLS(LauncherUtils.getArgSmtpTLS(arguments)); this.getConfig().setSmtpUsername(LauncherUtils.getArgSmtpUsername(arguments)); this.getConfig().setSmtpPassword(LauncherUtils.getArgSmtpPassword(arguments)); this.getConfig().setNotifyTo(LauncherUtils.getArgNotifyto(arguments)); if (LauncherUtils.getArgPushUrl(arguments) != null) { this.getConfig().setPush(true); this.getConfig().setPushRemoteRepo(LauncherUtils.getArgPushUrl(arguments)); } this.getConfig().setCreatePR(LauncherUtils.getArgCreatePR(arguments)); // we fork if we need to create a PR or if we need to notify (but only when we have a git token) if (this.getConfig().isCreatePR() || (this.getConfig().getSmtpServer() != null && !this.getConfig().getSmtpServer().isEmpty() && this.getConfig().getNotifyTo() != null && this.getConfig().getNotifyTo().length > 0 && this.getConfig().getGithubToken() != null)) { this.getConfig().setFork(true); } this.getConfig().setBuildId(arguments.getInt("build")); if (this.getConfig().getLauncherMode() == LauncherMode.BEARS) { this.getConfig().setNextBuildId(arguments.getInt("nextBuild")); } this.getConfig().setZ3solverPath(new File(arguments.getString("z3")).getPath()); this.getConfig().setWorkspacePath(arguments.getString("workspace")); if (arguments.getBoolean("tmpDirAsWorkSpace")) { this.tempDir = com.google.common.io.Files.createTempDir(); this.getConfig().setWorkspacePath(this.tempDir.getAbsolutePath()); this.getConfig().setOutputPath(this.tempDir.getAbsolutePath()); this.getConfig().setZ3solverPath(new File(this.tempDir.getAbsolutePath() + File.separator + "z3_for_linux").getPath()); } this.getConfig().setGithubUserEmail(LauncherUtils.getArgGithubUserEmail(arguments)); this.getConfig().setGithubUserName(LauncherUtils.getArgGithubUserName(arguments)); this.getConfig().setListenerMode(arguments.getString("listenermode")); this.getConfig().setActiveMQUrl(arguments.getString("activemqurl")); this.getConfig().setActiveMQListenQueueName(arguments.getString("activemqlistenqueuename")); this.getConfig().setActiveMQUsername(arguments.getString("activemqusername")); this.getConfig().setActiveMQPassword(arguments.getString("activemqpassword")); this.getConfig().setGitUrl(arguments.getString("giturl")); this.getConfig().setGitBranch(arguments.getString("gitbranch")); this.getConfig().setGitCommitHash(arguments.getString("gitcommithash")); this.getConfig().setMavenHome(arguments.getString("MavenHome")); this.getConfig().setNoTravisRepair(arguments.getBoolean("noTravisRepair")); if (arguments.getFile("projectsToIgnore") != null) { this.getConfig().setProjectsToIgnoreFilePath(arguments.getFile("projectsToIgnore").getPath()); } this.getConfig().setRepairTools(new HashSet<>(Arrays.asList(arguments.getStringArray("repairTools")))); if (this.getConfig().getLauncherMode() == LauncherMode.REPAIR) { LOGGER.info("The following repair tools will be used: " + StringUtils.join(this.getConfig().getRepairTools(), ", ")); } // Make sure that it is a multiple of three in the list if((arguments.getStringArray("experimentalPluginRepoList").length) % 3 == 0) { this.getConfig().setExperimentalPluginRepoList(arguments.getStringArray("experimentalPluginRepoList")); } else if (arguments.getStringArray("experimentalPluginRepoList").length != 0) { LOGGER.warn("The experimental plugin repo list is not correctly formed." + " Please make sure you have provided id, name and url for all repos. " + "Repairnator will continue without these repos."); this.getConfig().setExperimentalPluginRepoList(null); } else { this.getConfig().setExperimentalPluginRepoList(null); } }
Example 5
Source File: GithubInitConfig.java From repairnator with MIT License | 4 votes |
@Override public void initConfigWithJSAP(JSAP jsap, String[] inputArgs) { JSAPResult arguments = jsap.parse(inputArgs); if (LauncherUtils.getArgDebug(arguments)) { getConfig().setDebug(true); } getConfig().setClean(true); getConfig().setRunId(LauncherUtils.getArgRunId(arguments)); getConfig().setGithubToken(LauncherUtils.getArgGithubOAuth(arguments)); if (GitRepositoryLauncherUtils.getArgGitRepositoryMode(arguments)) { if (GitRepositoryLauncherUtils.getArgGitRepositoryFirstCommit(arguments)) { getConfig().setGitRepositoryFirstCommit(true); } } else { System.err.println("Error: Parameter 'gitrepo' is required in GIT_REPOSITORY launcher mode."); } if (LauncherUtils.getArgOutput(arguments) != null) { getConfig().setOutputPath(LauncherUtils.getArgOutput(arguments).getPath()); } getConfig().setMongodbHost(LauncherUtils.getArgMongoDBHost(arguments)); getConfig().setMongodbName(LauncherUtils.getArgMongoDBName(arguments)); getConfig().setSmtpServer(LauncherUtils.getArgSmtpServer(arguments)); getConfig().setSmtpPort(LauncherUtils.getArgSmtpPort(arguments)); getConfig().setSmtpTLS(LauncherUtils.getArgSmtpTLS(arguments)); getConfig().setSmtpUsername(LauncherUtils.getArgSmtpUsername(arguments)); getConfig().setSmtpPassword(LauncherUtils.getArgSmtpPassword(arguments)); getConfig().setNotifyTo(LauncherUtils.getArgNotifyto(arguments)); if (LauncherUtils.getArgPushUrl(arguments) != null) { getConfig().setPush(true); getConfig().setPushRemoteRepo(LauncherUtils.getArgPushUrl(arguments)); } getConfig().setCreatePR(LauncherUtils.getArgCreatePR(arguments)); // we fork if we need to create a PR or if we need to notify if ((getConfig().isCreatePR() || (getConfig().getSmtpServer() != null && !getConfig().getSmtpServer().isEmpty() && getConfig().getNotifyTo() != null && getConfig().getNotifyTo().length > 0)) && getConfig().getGithubToken() != null) { getConfig().setFork(true); } if (arguments.getString("gitRepositoryUrl") == null) { System.err.println("Error: Parameter 'gitrepourl' is required in GIT_REPOSITORY launcher mode."); } if (getConfig().isGitRepositoryFirstCommit() && arguments.getString("gitRepositoryIdCommit") != null) { System.err.println("Error: Parameters 'gitrepofirstcommit' and 'gitrepoidcommit' cannot be used at the same time."); } getConfig().setGitRepositoryUrl(arguments.getString("gitRepositoryUrl")); getConfig().setGitRepositoryBranch(arguments.getString("gitRepositoryBranch")); getConfig().setGitRepositoryIdCommit(arguments.getString("gitRepositoryIdCommit")); getConfig().setZ3solverPath(new File(arguments.getString("z3")).getPath()); getConfig().setWorkspacePath(arguments.getString("workspace")); if (arguments.getBoolean("tmpDirAsWorkSpace")) { tempDir = com.google.common.io.Files.createTempDir(); getConfig().setWorkspacePath(tempDir.getAbsolutePath()); getConfig().setOutputPath(tempDir.getAbsolutePath()); getConfig().setZ3solverPath(new File(tempDir.getAbsolutePath() + File.separator + "z3_for_linux").getPath()); } getConfig().setGithubUserEmail(LauncherUtils.getArgGithubUserEmail(arguments)); getConfig().setGithubUserName(LauncherUtils.getArgGithubUserName(arguments)); getConfig().setListenerMode(arguments.getString("listenermode")); getConfig().setActiveMQUrl(arguments.getString("activemqurl")); getConfig().setActiveMQListenQueueName(arguments.getString("activemqlistenqueuename")); getConfig().setGitUrl(arguments.getString("giturl")); getConfig().setGitBranch(arguments.getString("gitbranch")); getConfig().setGitCommitHash(arguments.getString("gitcommithash")); getConfig().setMavenHome(arguments.getString("MavenHome")); if (arguments.getFile("projectsToIgnore") != null) { getConfig().setProjectsToIgnoreFilePath(arguments.getFile("projectsToIgnore").getPath()); } getConfig().setRepairTools(new HashSet<>(Arrays.asList(arguments.getStringArray("repairTools")))); // Make sure that it is a multiple of three in the list if((arguments.getStringArray("experimentalPluginRepoList").length) % 3 == 0) { getConfig().setExperimentalPluginRepoList(arguments.getStringArray("experimentalPluginRepoList")); } else if (arguments.getStringArray("experimentalPluginRepoList").length != 0) { LOGGER.warn("The experimental plugin repo list is not correctly formed." + " Please make sure you have provided id, name and url for all repos. " + "Repairnator will continue without these repos."); getConfig().setExperimentalPluginRepoList(null); } else { getConfig().setExperimentalPluginRepoList(null); } }
Example 6
Source File: LauncherUtils.java From repairnator with MIT License | 4 votes |
public static String[] getArgNotifyto(JSAPResult arguments) { return arguments.getStringArray("notifyto"); }