Examples of SimpleCommandLineParser


Examples of sample.util.SimpleCommandLineParser

  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

Examples of sample.util.SimpleCommandLineParser

  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

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

Examples of sample.util.SimpleCommandLineParser

    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

Examples of sample.util.SimpleCommandLineParser

  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

Examples of sample.util.SimpleCommandLineParser

   *
   * @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

Examples of sample.util.SimpleCommandLineParser

   * <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

Examples of sample.util.SimpleCommandLineParser

   * 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

Examples of sample.util.SimpleCommandLineParser

  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

Examples of sample.util.SimpleCommandLineParser

   * @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
TOP
Copyright © 2018 www.massapi.com. 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.