Package sample.util

Examples of sample.util.SimpleCommandLineParser


    output.println("Keywords after update: "
        + updatedEntry.getMediaGroup().getKeywords().getKeywords());
  }

  public static void main(String[] args) throws IOException, ServiceException {
    SimpleCommandLineParser parser = new SimpleCommandLineParser(args);
    String username = parser.getValue("username", "user", "u");
    String password = parser.getValue("password", "pass", "p");
    String developerKey = parser.getValue("key", "k");
    boolean help = parser.containsKey("help", "h");

    if (help || username == null || password == null || developerKey == null) {
      printUsage();
      System.exit(1);
    }
View Full Code Here


   * This sample demonstrates both upload and write activities in the API.
   *
   * @param args Used to pass the username and password of a test account.
   */
  public static void main(String[] args) {
    SimpleCommandLineParser parser = new SimpleCommandLineParser(args);
    String username = parser.getValue("username", "user", "u");
    String password = parser.getValue("password", "pass", "p");
    String developerKey = parser.getValue("key", "k");
    boolean help = parser.containsKey("help", "h");

    if (help || username == null || password == null || developerKey == null) {
      printUsage();
      System.exit(1);
    }
View Full Code Here

   * @param args See the usage method.
   */
  public static void main(String[] args) {

    // Set 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");
    boolean help = parser.containsKey("help", "h");
    if (help || (userName == null) || (userPassword == null)) {
      usage();
      System.exit(1);
    }

View Full Code Here

   * uses resumable upload feature to upload large media.
   *
   * @param args Used to pass the username and password of a test account.
   */
  public static void main(String[] args) {
    SimpleCommandLineParser parser = new SimpleCommandLineParser(args);
    String username = parser.getValue("username", "user", "u");
    String password = parser.getValue("password", "pass", "p");
    String developerKey = parser.getValue("key", "k");
    boolean help = parser.containsKey("help", "h");

    if (help || username == null || password == null || developerKey == null) {
      printUsage();
      System.exit(1);
    }
View Full Code Here

   *                                     --admin_password [pass]
   *                                     --domain [domain]
   */
  public static void main(String[] arg)
      throws Exception {
    SimpleCommandLineParser parser = new SimpleCommandLineParser(arg);
    String adminEmail = parser.getValue("admin_email", "email", "e");
    String adminPassword = parser.getValue("admin_password", "pass", "p");
    String domain = parser.getValue("domain", "domain", "d");

    boolean help = parser.containsKey("help", "h");
    if (help || (adminEmail == null) || (adminPassword == null) || (domain == null)) {
      usage();
      System.exit(1);
    }

View Full Code Here

  /**
   * @param args
   */
  public static void main(String[] args) {
    SimpleCommandLineParser parser = new SimpleCommandLineParser(args);
    String adminEmail = parser.getValue("admin_email", "email", "e");
    String adminPassword = parser.getValue("admin_password", "pass", "p");
    String domain = parser.getValue("domain", "domain", "d");

    boolean help = parser.containsKey("help", "h");
    if (help || (adminEmail == null) || (adminPassword == null) || (domain == null)) {
      usage();
      System.exit(1);
    }

View Full Code Here

   * Usage: java AppsForYourDomainMigrationClient --username <user>
   * --password <pass> --domain <domain>
   * [--destination_user <destination_user>] [--data_file <file>]
   */
  public static void main(String[] arg) throws Exception {
    SimpleCommandLineParser parser = new SimpleCommandLineParser(arg);

    // Parse command-line flags
    String username = parser.getValue("username");
    String password = parser.getValue("password");
    String domain = parser.getValue("domain");
    String destinationUser = parser.getValue("destination_user");
    String emailFileName = parser.getValue("data_file");
   
    boolean help = parser.containsKey("help");
    if (help || (username == null) || (password == null)
             || (domain == null)) {
      usage();
      System.exit(1);
    }
View Full Code Here

    printResults(resultFeed);
  }

  private DocumentQuery createQueryFromArgs(String[] args) throws IOException {
    SimpleCommandLineParser parser = new SimpleCommandLineParser(args);

    System.out.println("You asked to list documents....");

    URL feedUrl = FeedUris.getDocumentsFeedUrl();
    DocumentQuery query = new DocumentQuery(feedUrl);

    if (parser.containsKey("onlydeleted")) {
      System.out.println("...that are deleted");
      query.setOnlydeleted(true);
    }

    if (parser.containsKey("onlyhidden")) {
      System.out.println("...that are hidden");
      Query.CategoryFilter filter = new Query.CategoryFilter();
      filter.addCategory(new HiddenCategory());
      query.addCategoryFilter(filter);
    }

    if (parser.containsKey("excludehidden")) {
      System.out.println("...that are not hidden");
      Query.CategoryFilter filter = new Query.CategoryFilter();
      filter.addExcludeCategory(new HiddenCategory());
      query.addCategoryFilter(filter);
    }

    String sharedWithEmail = parser.getValue("sharedwith");
    if (sharedWithEmail != null) {
      System.out.println("...that are shared with " + sharedWithEmail);
      query.setSharedWithEmailId(sharedWithEmail);
    }

    String startIndex = parser.getValue("start-index");
    if (startIndex != null) {
      System.out.println("...that start from position " + startIndex);
      query.setStartIndex(Integer.parseInt(startIndex));
    }

    String maxResults = parser.getValue("max-results");
    if (maxResults != null) {
      System.out.println("...and you don't want more than " + maxResults
          + " results");
      query.setMaxResults(Integer.parseInt(maxResults));
    }
View Full Code Here

  private DownloadDocumentCommand() {
  }

  public void execute(GttService service, String[] args)
      throws IOException, ServiceException {
    SimpleCommandLineParser parser = new SimpleCommandLineParser(args);

    String id = parser.getValue("id");
    URL feedUrl = FeedUris.getDocumentDownloadFeedUrl(id);

    String targetFile = parser.getValue("file");

    System.out.print("Downloading document with id :" + id + " ....");
    System.out.flush();

    MediaContent mc = new MediaContent();
View Full Code Here

  private UpdateTranslationMemoryCommand() {
  }

  public void execute(GttService service, String[] args)
      throws IOException, ServiceException {
    SimpleCommandLineParser parser = new SimpleCommandLineParser(args);

    String id = parser.getValue("id");
    URL feedUrl = FeedUris.getTranslationMemoryFeedUrl(id);

    TranslationMemoryEntry requestEntry = service.getEntry(feedUrl,
        TranslationMemoryEntry.class);

    System.out.println("You want to update translation memory with id:"
        + id + " ...");

    if (parser.containsKey("title")) {
      String title = parser.getValue("title");
      System.out.println("...by changing title to " + title);
      requestEntry.setTitle(new PlainTextConstruct(title));
    }

    if (parser.containsKey("file")) {
      String filename = parser.getValue("file");
      System.out.println("...by appending contents from file " + filename);
      File file = new File(filename);
      String mimeType = "text/xml";

      MediaFileSource fileSource = new MediaFileSource(file, mimeType);
View Full Code Here

TOP

Related Classes of sample.util.SimpleCommandLineParser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.