List of usage examples for org.apache.commons.cli CommandLine getArgs
public String[] getArgs()
From source file:ch.ethz.topobench.graph.patheval.generators.NeighborPathEvaluatorGenerator.java
@Override public SelectorResult<PathEvaluator> generate(Graph graph, String[] args) { // Parse the options CommandLine cmd = CmdAssistant.parseOptions(new Options(), args, true); // Return path evaluator return new SelectorResult<>(new NeighborPathEvaluator(graph), cmd.getArgs()); }
From source file:com.model.database.GtfsDatabaseLoaderMain.java
private void run(String[] args) throws IOException { CommandLine cli = parseCommandLineOptions(args); args = cli.getArgs(); if (args.length != 1) { printUsage();/* w ww .j a v a 2 s . c om*/ System.exit(-1); } Configuration config = new Configuration(); config.setProperty("hibernate.connection.driver_class", cli.getOptionValue(ARG_DRIVER_CLASS)); config.setProperty("hibernate.connection.url", cli.getOptionValue(ARG_URL)); if (cli.hasOption(ARG_USERNAME)) { config.setProperty("hibernate.connection.username", cli.getOptionValue(ARG_USERNAME)); } if (cli.hasOption(ARG_PASSWORD)) { config.setProperty("hibernate.connection.password", cli.getOptionValue(ARG_PASSWORD)); } config.setProperty("hibernate.connection.pool_size", "1"); config.setProperty("hibernate.cache.provider_class", "org.hibernate.cache.NoCacheProvider"); config.setProperty("hibernate.hbm2ddl.auto", "update"); config.addResource("com/model/database/connections/transit/mapping/GtfsMapping.hibernate.xml"); config.addResource( "com/model/database/connections/transit/mapping/HibernateGtfsRelationalDaoImpl.hibernate.xml"); SessionFactory sessionFactory = config.buildSessionFactory(); HibernateGtfsFactory factory = new HibernateGtfsFactory(sessionFactory); GtfsReader reader = new GtfsReader(); reader.setInputLocation(new File(args[0])); GtfsMutableRelationalDao dao = factory.getDao(); reader.setEntityStore(dao); try { reader.run(); } catch (Exception e) { DbUpdate.gtfsMessage = e.getMessage(); DbUpdate.gtfsUpload = true; } finally { reader.close(); sessionFactory.close(); } }
From source file:com.netscape.cmstools.client.ClientCertFindCLI.java
public void execute(String[] args) throws Exception { // Always check for "--help" prior to parsing if (Arrays.asList(args).contains("--help")) { printHelp();//from w w w .j a v a 2s. c o m return; } CommandLine cmd = parser.parse(options, args); String[] cmdArgs = cmd.getArgs(); if (cmdArgs.length != 0) { throw new Exception("Too many arguments specified."); } CryptoManager manager = CryptoManager.getInstance(); X509Certificate[] certs; if (cmd.hasOption("ca")) { certs = manager.getCACerts(); } else { certs = manager.getPermCerts(); } if (certs == null || certs.length == 0) { MainCLI.printMessage("No certificates found"); return; } MainCLI.printMessage(certs.length + " certificate(s) found"); boolean first = true; for (X509Certificate cert : certs) { if (first) { first = false; } else { System.out.println(); } ClientCLI.printCertInfo(cert); } MainCLI.printMessage("Number of entries returned " + certs.length); }
From source file:com.netscape.cmstools.user.UserAddCLI.java
public void execute(String[] args) throws Exception { // Always check for "--help" prior to parsing if (Arrays.asList(args).contains("--help")) { printHelp();//from w w w. j ava 2 s. co m return; } CommandLine cmd = parser.parse(options, args); String[] cmdArgs = cmd.getArgs(); if (cmdArgs.length != 1) { throw new Exception("No User ID specified."); } String userID = cmdArgs[0]; UserData userData = new UserData(); userData.setUserID(userID); userData.setFullName(cmd.getOptionValue("fullName")); userData.setEmail(cmd.getOptionValue("email")); userData.setPassword(cmd.getOptionValue("password")); userData.setPhone(cmd.getOptionValue("phone")); userData.setType(cmd.getOptionValue("type")); userData.setState(cmd.getOptionValue("state")); UserClient userClient = userCLI.getUserClient(); userData = userClient.addUser(userData); MainCLI.printMessage("Added user \"" + userID + "\""); UserCLI.printUser(userData); }
From source file:com.netscape.cmstools.group.GroupFindCLI.java
public void execute(String[] args) throws Exception { // Always check for "--help" prior to parsing if (Arrays.asList(args).contains("--help")) { printHelp();//www.j av a 2s . c o m return; } CommandLine cmd = parser.parse(options, args); String[] cmdArgs = cmd.getArgs(); String filter = cmdArgs.length > 0 ? cmdArgs[0] : null; String s = cmd.getOptionValue("start"); Integer start = s == null ? null : Integer.valueOf(s); s = cmd.getOptionValue("size"); Integer size = s == null ? null : Integer.valueOf(s); GroupClient groupClient = groupCLI.getGroupClient(); GroupCollection response = groupClient.findGroups(filter, start, size); MainCLI.printMessage(response.getTotal() + " entries matched"); if (response.getTotal() == 0) return; Collection<GroupData> entries = response.getEntries(); boolean first = true; for (GroupData groupData : entries) { if (first) { first = false; } else { System.out.println(); } GroupCLI.printGroup(groupData); } MainCLI.printMessage("Number of entries returned " + entries.size()); }
From source file:com.netscape.cmstools.logging.ActivityFindCLI.java
public void execute(String[] args) throws Exception { // Always check for "--help" prior to parsing if (Arrays.asList(args).contains("--help")) { printHelp();//from w w w.j av a2 s. c o m return; } CommandLine cmd = parser.parse(options, args); String[] cmdArgs = cmd.getArgs(); String filter = cmdArgs.length > 0 ? cmdArgs[0] : null; String s = cmd.getOptionValue("start"); Integer start = s == null ? null : Integer.valueOf(s); s = cmd.getOptionValue("size"); Integer size = s == null ? null : Integer.valueOf(s); ActivityClient activityClient = activityCLI.getActivityClient(); ActivityCollection result = activityClient.findActivities(filter, start, size); MainCLI.printMessage(result.getTotal() + " entries matched"); if (result.getTotal() == 0) return; Collection<ActivityData> activities = result.getEntries(); boolean first = true; for (ActivityData activityData : activities) { if (first) { first = false; } else { System.out.println(); } ActivityCLI.printActivity(activityData, false); } MainCLI.printMessage("Number of entries returned " + activities.size()); }
From source file:com.netscape.cmstools.selftests.SelfTestFindCLI.java
public void execute(String[] args) throws Exception { // Always check for "--help" prior to parsing if (Arrays.asList(args).contains("--help")) { printHelp();//from w ww . j a v a 2 s .c o m return; } CommandLine cmd = parser.parse(options, args); String[] cmdArgs = cmd.getArgs(); String filter = cmdArgs.length > 0 ? cmdArgs[0] : null; String s = cmd.getOptionValue("start"); Integer start = s == null ? null : Integer.valueOf(s); s = cmd.getOptionValue("size"); Integer size = s == null ? null : Integer.valueOf(s); SelfTestClient selfTestClient = selfTestCLI.getSelfTestClient(); SelfTestCollection result = selfTestClient.findSelfTests(filter, start, size); MainCLI.printMessage(result.getTotal() + " entries matched"); if (result.getTotal() == 0) return; Collection<SelfTestData> selfTests = result.getEntries(); boolean first = true; for (SelfTestData selfTestInfo : selfTests) { if (first) { first = false; } else { System.out.println(); } SelfTestCLI.printSelfTestData(selfTestInfo); } MainCLI.printMessage("Number of entries returned " + selfTests.size()); }
From source file:com.netscape.cmstools.tps.authenticator.AuthenticatorFindCLI.java
public void execute(String[] args) throws Exception { // Always check for "--help" prior to parsing if (Arrays.asList(args).contains("--help")) { printHelp();/* w ww. j a v a2 s. co m*/ return; } CommandLine cmd = parser.parse(options, args); String[] cmdArgs = cmd.getArgs(); String filter = cmdArgs.length > 0 ? cmdArgs[0] : null; String s = cmd.getOptionValue("start"); Integer start = s == null ? null : Integer.valueOf(s); s = cmd.getOptionValue("size"); Integer size = s == null ? null : Integer.valueOf(s); AuthenticatorClient authenticatorClient = authenticatorCLI.getAuthenticatorClient(); AuthenticatorCollection result = authenticatorClient.findAuthenticators(filter, start, size); MainCLI.printMessage(result.getTotal() + " entries matched"); if (result.getTotal() == 0) return; Collection<AuthenticatorData> authenticators = result.getEntries(); boolean first = true; for (AuthenticatorData authenticatorData : authenticators) { if (first) { first = false; } else { System.out.println(); } AuthenticatorCLI.printAuthenticatorData(authenticatorData, false); } MainCLI.printMessage("Number of entries returned " + authenticators.size()); }
From source file:com.netscape.cmstools.tps.connector.ConnectorFindCLI.java
public void execute(String[] args) throws Exception { // Always check for "--help" prior to parsing if (Arrays.asList(args).contains("--help")) { printHelp();/*ww w . ja v a 2s . c o m*/ return; } CommandLine cmd = parser.parse(options, args); String[] cmdArgs = cmd.getArgs(); String filter = cmdArgs.length > 0 ? cmdArgs[0] : null; String s = cmd.getOptionValue("start"); Integer start = s == null ? null : Integer.valueOf(s); s = cmd.getOptionValue("size"); Integer size = s == null ? null : Integer.valueOf(s); ConnectorClient connectorClient = connectorCLI.getConnectorClient(); ConnectorCollection result = connectorClient.findConnectors(filter, start, size); MainCLI.printMessage(result.getTotal() + " entries matched"); if (result.getTotal() == 0) return; Collection<ConnectorData> connectors = result.getEntries(); boolean first = true; for (ConnectorData connectorData : connectors) { if (first) { first = false; } else { System.out.println(); } ConnectorCLI.printConnectorData(connectorData, false); } MainCLI.printMessage("Number of entries returned " + connectors.size()); }
From source file:com.netscape.cmstools.tps.profile.ProfileFindCLI.java
public void execute(String[] args) throws Exception { // Always check for "--help" prior to parsing if (Arrays.asList(args).contains("--help")) { printHelp();//from w w w . jav a2 s .c o m return; } CommandLine cmd = parser.parse(options, args); String[] cmdArgs = cmd.getArgs(); String filter = cmdArgs.length > 0 ? cmdArgs[0] : null; String s = cmd.getOptionValue("start"); Integer start = s == null ? null : Integer.valueOf(s); s = cmd.getOptionValue("size"); Integer size = s == null ? null : Integer.valueOf(s); ProfileClient profileClient = profileCLI.getProfileClient(); ProfileCollection result = profileClient.findProfiles(filter, start, size); MainCLI.printMessage(result.getTotal() + " entries matched"); if (result.getTotal() == 0) return; Collection<ProfileData> profiles = result.getEntries(); boolean first = true; for (ProfileData profileData : profiles) { if (first) { first = false; } else { System.out.println(); } ProfileCLI.printProfileData(profileData, false); } MainCLI.printMessage("Number of entries returned " + profiles.size()); }