/** * Runs the demo. * * @param args the command-line arguments * @throws AuthenticationException if the service is unable to validate the username and password. */ public static void main(String[] args) throws AuthenticationException { SimpleCommandLineParser parser = new SimpleCommandLineParser(args); String username = parser.getValue("username", "user", "u"); String password = parser.getValue("password", "pass", "p"); boolean help = parser.containsKey("help", "h"); if (help || username == null || password == null) { usage(); System.exit(1); } CellDemo demo = new CellDemo(new SpreadsheetService("Cell Demo"), System.out); demo.run(username, password); }
public void execute(GttService gttService, String[] args) throws ServiceException { // Get username, password and feed URI from command-line arguments. SimpleCommandLineParser parser = new SimpleCommandLineParser(args); String userName = parser.getValue("username", "user", "u"); String userPassword = parser.getValue("password", "pass", "p"); if (parser.containsKey("baseuri")) { FeedUris.setBaseUrl(parser.getValue("baseuri")); } if (userName == null || userPassword == null) { System.out.println(helpString()); } else { // Authenticate using ClientLogin gttService.setUserCredentials(userName, userPassword); System.out.println("\nYou're now logged in as " + userName + "!"); } }