Package sample.util

Examples of sample.util.SimpleCommandLineParser


    }
  }

  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");
    boolean help = parser.containsKey("help", "h");

    if (help || username == null || password == null) {
      usage();
      System.exit(1);
    }

    if (parser.containsKey("log", "l")) {
      turnOnLogging();
    }

    HealthDemo demo = new HealthDemo(
        new HealthService("Sample Health Client"), System.out);
View Full Code Here


    printResults(resultFeed);
  }

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

    URL feedUrl = FeedUris.getGlossariesFeedUrl();
    Query query = new Query(feedUrl);

    return query;
View Full Code Here

  private UpdateGlossaryCommand() {
  }

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

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

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

    System.out.println("You want to update glossary 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/csv";

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

   *
   * @param args See the usage method.
   */
  public static void main(String[] args) {
    // Get username and password 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

   * <li>webclip</li>
   * <li>delegation</li>
   * </ul>
   */
  public static void main(String[] arg) {
    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 delegationEmailId = parser.getValue("delegationEmailId");
    String setting = parser.getValue("setting");
    boolean doGet = parser.containsKey("get");
    boolean doDelete = parser.containsKey("delete");
    boolean doAddOrUpdate = false;

    boolean help = parser.containsKey("help");
    boolean enable = !parser.containsKey("disable");
    if (doGet && doDelete) {
      System.out.println(
          "Choose method as one of --get or --delete, or leave blank for create/update.\n");
      printUsageAndExit();
    } else if (!doGet && !doDelete) {
View Full Code Here

   * Usage: java AppsForYourDomainGmailFilterClient --username &lt;user&gt;
   * --password &lt;pass&gt; --domain &lt;domain&gt;
   * --destination_user &lt;destination_user&gt;
   */
  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");

    boolean help = parser.containsKey("help");
    if (help || (username == null) || (password == null) || (domain == null)) {
      usage();
      System.exit(1);
    }

View Full Code Here

  private UpdateDocumentCommand() {
  }

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

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

    DocumentEntry requestEntry = service.getEntry(feedUrl, DocumentEntry.class);
    requestEntry.setLastModifiedBy(null);

    System.out.println("You want to update document 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("tmids")) {
      String tmIds = parser.getValue("tmids");
      System.out.println("...by adding translation memories with ids: "
          + tmIds);
      TmsElement tm = new TmsElement();
      for (String tmId : tmIds.split(",")) {
        String tmHref = FeedUris.getTranslationMemoryFeedUrl(tmId).toString();

        Link tmLink = new Link();
        tmLink.setHref(tmHref);

        tm.addLink(tmLink);
      }
      requestEntry.setTranslationMemory(tm);
    }

    if (parser.containsKey("glids")) {
      String glIds = parser.getValue("glids");
      System.out.println("...by adding glossaries with ids: "
          + glIds);
      GlossariesElement gl = new GlossariesElement();
      for (String glId : glIds.split(",")) {
        String glHref = FeedUris.getGlossaryFeedUrl(glId).toString();
View Full Code Here

   * @throws DocumentListException
   * @throws ServiceException
   * @throws IOException
   */
  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 token = parser.getValue("token", "token", "t");
    String domain = parser.getValue("domain", "d");
    String siteName = parser.getValue("siteName", "site", "s");
    boolean help = parser.containsKey("help", "h");
    boolean logItUp = parser.containsKey("log", "l");

    if (siteName == null || help) {
      printMessage(USAGE_MESSAGE);
      System.exit(1);
    }
View Full Code Here

    printResults(resultEntry);
  }

  private DocumentEntry createEntryFromArgs(String[] args) throws IOException {
    SimpleCommandLineParser parser = new SimpleCommandLineParser(args);

    DocumentEntry entry = new DocumentEntry();

    System.out.println("You want to create a new document...");

    String srcLang = parser.getValue("srclang");
    System.out.println("... with source language " + srcLang);
    entry.setSourceLanguage(new SourceLanguage(srcLang));

    String targetLang = parser.getValue("targetlang");
    System.out.println("... with target language " + targetLang);
    entry.setTargetLanguage(new TargetLanguage(targetLang));

    String title = parser.getValue("title");
    System.out.println("... with title " + title);
    entry.setTitle(new PlainTextConstruct(title));

    if (parser.containsKey("weburl")) {
      String url = parser.getValue("weburl");
      System.out.println("... with html contents from " + url);
      DocumentSource docSource = new DocumentSource(DocumentSource.Type.HTML,
          url);
      entry.setDocumentSource(docSource);
    } else if (parser.containsKey("wikipediaurl")) {
      String url = parser.getValue("wikipediaurl");
      System.out.println("... with mediawiki contents from " + url);
      DocumentSource docSource = new DocumentSource(DocumentSource.Type.WIKI,
          url);
      entry.setDocumentSource(docSource);
    } else if (parser.containsKey("knolurl")) {
      String url = parser.getValue("knolurl");
      System.out.println("... with knol contents from " + url);
      DocumentSource docSource = new DocumentSource(DocumentSource.Type.KNOL,
          url);
      entry.setDocumentSource(docSource);
    } else if (parser.containsKey("file")) {
      String filename = parser.getValue("file");
      System.out.println("... with contents from file at " + filename);
      File file = new File(filename);
      String mimeType = MediaType.fromFileName(filename).getMimeType();

      MediaFileSource fileSource = new MediaFileSource(file, mimeType);
      MediaContent content = new MediaContent();
      content.setMediaSource(fileSource);
      content.setMimeType(new ContentType(mimeType));

      entry.setContent(content);
    }

    if (parser.containsKey("tmids")) {
      String tmIds = parser.getValue("tmids");
      System.out.println("...by adding translation memories with ids: "
          + tmIds);
      TmsElement tm = new TmsElement();
      for (String id : tmIds.split(",")) {
        String tmHref = FeedUris.getTranslationMemoryFeedUrl(id).toString();

        Link tmLink = new Link();
        tmLink.setHref(tmHref);

        tm.addLink(tmLink);
      }
      entry.setTranslationMemory(tm);
    }

    if (parser.containsKey("glids")) {
      String glIds = parser.getValue("glids");
      System.out.println("...by adding glossaries with ids: "
          + glIds);
      GlossariesElement gl = new GlossariesElement();
      for (String id : glIds.split(",")) {
        String glHref = FeedUris.getGlossaryFeedUrl(id).toString();
View Full Code Here

  private DeleteDocumentCommand() {
  }

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

    String docId = parser.getValue("id");
    boolean deletePermanently = parser.containsKey("perm");

    URL feedUrl;
    if (deletePermanently) {
      feedUrl = FeedUris.getDocumentPermDeleteUrl(docId);
    } else {
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.