/*
 * Copyright 2012-2016 JetBrains s.r.o
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package jetbrains.jetpad.model.id;

import java.io.FileOutputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

public class BaseIdGenerator {
  private static final int DEFAULT_NUM_IDS = 5;
  private static final String USAGE = "usage: num_ids file_to_save_in";

  public static void main(String[] args) {
    int numIds;
    if (args.length >= 1) {
      try {
        numIds = Integer.parseInt(args[0]);
      } catch (Exception e) {
        System.out.println(USAGE);
        return;
      }
    } else {
      numIds = DEFAULT_NUM_IDS;
    }

    OutputStream out;
    if (args.length >= 2) {
      try {
        out = new FileOutputStream(args[1]);
      } catch (Exception e) {
        System.out.println(USAGE);
        return;
      }
    } else {
      out = System.out;
    }

    try (PrintWriter writer = new PrintWriter(out)) {
      for (int i = 0; i < numIds; i++) {
        writer.println("\"" + new MyId().getId() + "\"");
      }
    }
  }

  private static class MyId extends BaseId {}
}
@@ -631,16 +631,127 @@
 el.id;%0A%0A
+import java.awt.Toolkit;%0Aimport java.awt.datatransfer.Clipboard;%0Aimport java.awt.datatransfer.StringSelection;%0A
 import j
@@ -1616,23 +1616,26 @@
     
-writer.println(
+String idString = 
 %22%5C%22%22
@@ -1662,19 +1662,79 @@
 ) + %22%5C%22%22
+;%0A        if (i == 0) %7B%0A          copyToClipboard(idString
 );%0A
+  
       %7D%0A
@@ -1737,17 +1737,316 @@
   %7D%0A    
-%7D
+    writer.println(idString);%0A      %7D%0A    %7D%0A  %7D%0A%0A  private static void copyToClipboard(String idString) %7B%0A    StringSelection stringSelection = new StringSelection(idString);%0A    Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();%0A    clipboard.setContents(stringSelection, null);
 %0A  %7D%0A%0A  

copy the first id to the clipboard