{"action":"created","comment":{"url":"https://api.github.com/repos/dart-lang/polymer-dart/pulls/comments/46563456","id":46563456,"diff_hunk":"@@ -0,0 +1,193 @@\n+// Copyright (c) 2014, the Dart project authors.  Please see the AUTHORS file\n+// for details. All rights reserved. Use of this source code is governed by a\n+// BSD-style license that can be found in the LICENSE file.\n+\n+/// Script to create boilerplate for a Polymer element.\n+/// Produces .dart and .html files for the element.\n+///\n+/// Run this script with pub run:\n+///\n+///     pub run polymer:new_element element-name [-o output_dir]\n+///\n+library polymer.bin.new_element;\n+\n+import 'dart:io';\n+import 'package:args/args.dart';\n+import 'package:path/path.dart' as path show absolute, dirname, join, split;\n+\n+void printUsage(ArgParser parser) {\n+  print('pub run polymer:new_element [-o output_dir] element-name');\n+  print(parser.getUsage());\n+}\n+\n+void main(List<String> args) {\n+  var parser = new ArgParser(allowTrailingOptions: true);\n+\n+  parser.addOption('output-dir', abbr: 'o', help: 'Output directory');\n+  parser.addFlag('help', abbr: 'h');\n+\n+  var options, element;\n+  try {\n+    options = parser.parse(args);\n+    if (options['help']) {\n+      printUsage(parser);\n+      return;\n+    }\n+    if (options.rest == null || options.rest.isEmpty) {\n+      throw new FormatException('No element specified');\n+    }\n+    element = options.rest[0];\n+    if (!_isPolymerElement(element)) {\n+      throw new FormatException('Must specify polymer-element to create.\\n'\n+      'polymer-element must be all lowercase with at least 1 hyphen.');\n+    }\n+  } catch (e) {\n+    print('$e\\n');\n+    printUsage(parser);\n+    exitCode = 1;\n+    return;\n+  }\n+\n+  var outputDir, startDir;\n+\n+  var outputPath = options['output-dir'];\n+\n+  if (outputPath == null) {\n+    if ((new File('pubspec.yaml')).existsSync()) {\n+      print('When creating elements in root directory of package, '\n+      '-o <dir> must be specified');\n+      exitCode = 1;\n+      return;\n+    }\n+    outputDir = (new Directory('.')).resolveSymbolicLinksSync();\n+  } else {\n+    var outputDirLocation = new Directory(outputPath);\n+    if (!outputDirLocation.existsSync()) {\n+      outputDirLocation.createSync(recursive: true);\n+    }\n+    outputDir = (new Directory(outputPath)).resolveSymbolicLinksSync();\n+  }\n+\n+  var pubspecDir = _findDirWithFile(outputDir, 'pubspec.yaml');\n+\n+  if (pubspecDir == null) {\n+    print('Could not find pubspec.yaml when walking up from $outputDir');\n+    exitCode = 1;\n+    return;\n+  }\n+\n+  var length = path.split(pubspecDir).length;\n+  var distanceToPackageRoot = path.split(outputDir).length - length;\n+\n+  // See dartbug.com/20076 for the algorithm used here.\n+  if (distanceToPackageRoot > 0) {\n+    if (path.split(outputDir)[length] == 'lib') {\n+      distanceToPackageRoot++;\n+    } else {\n+      distanceToPackageRoot--;\n+    }\n+  }\n+\n+  try {\n+    _createBoilerPlate(\n+        element, outputDir, distanceToPackageRoot);\n+  } on Exception catch (e, t) {\n+    print('Error creating files in $outputDir');\n+    print('$e $t');\n+    exitCode = 1;\n+    return;\n+  }\n+\n+  return;\n+}\n+\n+String _findDirWithFile(String dir, String filename) {\n+  while (!new File(path.join(dir, filename)).existsSync()) {\n+    var parentDir = path.dirname(dir);\n+    // If we reached root and failed to find it, bail.\n+    if (parentDir == dir) return null;\n+    dir = parentDir;\n+  }\n+  return dir;\n+}\n+\n+bool _isPolymerElement(String element) {\n+  return element.contains('-') && (element.toLowerCase() == element);\n+}\n+\n+String _toCamelCase(String s) {","path":"bin/new_element.dart","position":117,"original_position":118,"commit_id":"79bd4f534a28b12fcac02d866870a9b5c5d3bd9d","original_commit_id":"fe713df4e6a7567b4791e7d149c0181c59a6c371","user":{"login":"jakemac53","id":984921,"avatar_url":"https://avatars.githubusercontent.com/u/984921?v=3","gravatar_id":"","url":"https://api.github.com/users/jakemac53","html_url":"https://github.com/jakemac53","followers_url":"https://api.github.com/users/jakemac53/followers","following_url":"https://api.github.com/users/jakemac53/following{/other_user}","gists_url":"https://api.github.com/users/jakemac53/gists{/gist_id}","starred_url":"https://api.github.com/users/jakemac53/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jakemac53/subscriptions","organizations_url":"https://api.github.com/users/jakemac53/orgs","repos_url":"https://api.github.com/users/jakemac53/repos","events_url":"https://api.github.com/users/jakemac53/events{/privacy}","received_events_url":"https://api.github.com/users/jakemac53/received_events","type":"User","site_admin":false},"body":"All this really does is capitalize the first letter, I would either move all the CamelCase logic into this function or rename it.","created_at":"2015-12-03T15:16:39Z","updated_at":"2015-12-03T15:16:39Z","html_url":"https://github.com/dart-lang/polymer-dart/pull/657#discussion_r46563456","pull_request_url":"https://api.github.com/repos/dart-lang/polymer-dart/pulls/657","_links":{"self":{"href":"https://api.github.com/repos/dart-lang/polymer-dart/pulls/comments/46563456"},"html":{"href":"https://github.com/dart-lang/polymer-dart/pull/657#discussion_r46563456"},"pull_request":{"href":"https://api.github.com/repos/dart-lang/polymer-dart/pulls/657"}}},"pull_request":{"url":"https://api.github.com/repos/dart-lang/polymer-dart/pulls/657","id":52521470,"html_url":"https://github.com/dart-lang/polymer-dart/pull/657","diff_url":"https://github.com/dart-lang/polymer-dart/pull/657.diff","patch_url":"https://github.com/dart-lang/polymer-dart/pull/657.patch","issue_url":"https://api.github.com/repos/dart-lang/polymer-dart/issues/657","number":657,"state":"open","locked":false,"title":"Create Polymer 1.0 elements automatically","user":{"login":"eloypastor","id":8298906,"avatar_url":"https://avatars.githubusercontent.com/u/8298906?v=3","gravatar_id":"","url":"https://api.github.com/users/eloypastor","html_url":"https://github.com/eloypastor","followers_url":"https://api.github.com/users/eloypastor/followers","following_url":"https://api.github.com/users/eloypastor/following{/other_user}","gists_url":"https://api.github.com/users/eloypastor/gists{/gist_id}","starred_url":"https://api.github.com/users/eloypastor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eloypastor/subscriptions","organizations_url":"https://api.github.com/users/eloypastor/orgs","repos_url":"https://api.github.com/users/eloypastor/repos","events_url":"https://api.github.com/users/eloypastor/events{/privacy}","received_events_url":"https://api.github.com/users/eloypastor/received_events","type":"User","site_admin":false},"body":"Create Polymer 1.0 elements automatically. See:\r\nhttps://github.com/dart-lang/polymer-dart/wiki/feature-overview","created_at":"2015-12-03T11:20:34Z","updated_at":"2015-12-03T15:16:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5e0a4c099f4e4bb70c8bdd09003a0eec17e0daed","assignee":{"login":"jakemac53","id":984921,"avatar_url":"https://avatars.githubusercontent.com/u/984921?v=3","gravatar_id":"","url":"https://api.github.com/users/jakemac53","html_url":"https://github.com/jakemac53","followers_url":"https://api.github.com/users/jakemac53/followers","following_url":"https://api.github.com/users/jakemac53/following{/other_user}","gists_url":"https://api.github.com/users/jakemac53/gists{/gist_id}","starred_url":"https://api.github.com/users/jakemac53/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jakemac53/subscriptions","organizations_url":"https://api.github.com/users/jakemac53/orgs","repos_url":"https://api.github.com/users/jakemac53/repos","events_url":"https://api.github.com/users/jakemac53/events{/privacy}","received_events_url":"https://api.github.com/users/jakemac53/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/dart-lang/polymer-dart/pulls/657/commits","review_comments_url":"https://api.github.com/repos/dart-lang/polymer-dart/pulls/657/comments","review_comment_url":"https://api.github.com/repos/dart-lang/polymer-dart/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dart-lang/polymer-dart/issues/657/comments","statuses_url":"https://api.github.com/repos/dart-lang/polymer-dart/statuses/79bd4f534a28b12fcac02d866870a9b5c5d3bd9d","head":{"label":"eloypastor:1.0.0-rc.9","ref":"1.0.0-rc.9","sha":"79bd4f534a28b12fcac02d866870a9b5c5d3bd9d","user":{"login":"eloypastor","id":8298906,"avatar_url":"https://avatars.githubusercontent.com/u/8298906?v=3","gravatar_id":"","url":"https://api.github.com/users/eloypastor","html_url":"https://github.com/eloypastor","followers_url":"https://api.github.com/users/eloypastor/followers","following_url":"https://api.github.com/users/eloypastor/following{/other_user}","gists_url":"https://api.github.com/users/eloypastor/gists{/gist_id}","starred_url":"https://api.github.com/users/eloypastor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eloypastor/subscriptions","organizations_url":"https://api.github.com/users/eloypastor/orgs","repos_url":"https://api.github.com/users/eloypastor/repos","events_url":"https://api.github.com/users/eloypastor/events{/privacy}","received_events_url":"https://api.github.com/users/eloypastor/received_events","type":"User","site_admin":false},"repo":{"id":47327172,"name":"polymer-dart","full_name":"eloypastor/polymer-dart","owner":{"login":"eloypastor","id":8298906,"avatar_url":"https://avatars.githubusercontent.com/u/8298906?v=3","gravatar_id":"","url":"https://api.github.com/users/eloypastor","html_url":"https://github.com/eloypastor","followers_url":"https://api.github.com/users/eloypastor/followers","following_url":"https://api.github.com/users/eloypastor/following{/other_user}","gists_url":"https://api.github.com/users/eloypastor/gists{/gist_id}","starred_url":"https://api.github.com/users/eloypastor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eloypastor/subscriptions","organizations_url":"https://api.github.com/users/eloypastor/orgs","repos_url":"https://api.github.com/users/eloypastor/repos","events_url":"https://api.github.com/users/eloypastor/events{/privacy}","received_events_url":"https://api.github.com/users/eloypastor/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/eloypastor/polymer-dart","description":"Polymer support for Dart","fork":true,"url":"https://api.github.com/repos/eloypastor/polymer-dart","forks_url":"https://api.github.com/repos/eloypastor/polymer-dart/forks","keys_url":"https://api.github.com/repos/eloypastor/polymer-dart/keys{/key_id}","collaborators_url":"https://api.github.com/repos/eloypastor/polymer-dart/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/eloypastor/polymer-dart/teams","hooks_url":"https://api.github.com/repos/eloypastor/polymer-dart/hooks","issue_events_url":"https://api.github.com/repos/eloypastor/polymer-dart/issues/events{/number}","events_url":"https://api.github.com/repos/eloypastor/polymer-dart/events","assignees_url":"https://api.github.com/repos/eloypastor/polymer-dart/assignees{/user}","branches_url":"https://api.github.com/repos/eloypastor/polymer-dart/branches{/branch}","tags_url":"https://api.github.com/repos/eloypastor/polymer-dart/tags","blobs_url":"https://api.github.com/repos/eloypastor/polymer-dart/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/eloypastor/polymer-dart/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/eloypastor/polymer-dart/git/refs{/sha}","trees_url":"https://api.github.com/repos/eloypastor/polymer-dart/git/trees{/sha}","statuses_url":"https://api.github.com/repos/eloypastor/polymer-dart/statuses/{sha}","languages_url":"https://api.github.com/repos/eloypastor/polymer-dart/languages","stargazers_url":"https://api.github.com/repos/eloypastor/polymer-dart/stargazers","contributors_url":"https://api.github.com/repos/eloypastor/polymer-dart/contributors","subscribers_url":"https://api.github.com/repos/eloypastor/polymer-dart/subscribers","subscription_url":"https://api.github.com/repos/eloypastor/polymer-dart/subscription","commits_url":"https://api.github.com/repos/eloypastor/polymer-dart/commits{/sha}","git_commits_url":"https://api.github.com/repos/eloypastor/polymer-dart/git/commits{/sha}","comments_url":"https://api.github.com/repos/eloypastor/polymer-dart/comments{/number}","issue_comment_url":"https://api.github.com/repos/eloypastor/polymer-dart/issues/comments{/number}","contents_url":"https://api.github.com/repos/eloypastor/polymer-dart/contents/{+path}","compare_url":"https://api.github.com/repos/eloypastor/polymer-dart/compare/{base}...{head}","merges_url":"https://api.github.com/repos/eloypastor/polymer-dart/merges","archive_url":"https://api.github.com/repos/eloypastor/polymer-dart/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/eloypastor/polymer-dart/downloads","issues_url":"https://api.github.com/repos/eloypastor/polymer-dart/issues{/number}","pulls_url":"https://api.github.com/repos/eloypastor/polymer-dart/pulls{/number}","milestones_url":"https://api.github.com/repos/eloypastor/polymer-dart/milestones{/number}","notifications_url":"https://api.github.com/repos/eloypastor/polymer-dart/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/eloypastor/polymer-dart/labels{/name}","releases_url":"https://api.github.com/repos/eloypastor/polymer-dart/releases{/id}","created_at":"2015-12-03T11:14:38Z","updated_at":"2015-12-03T11:14:40Z","pushed_at":"2015-12-03T15:07:06Z","git_url":"git://github.com/eloypastor/polymer-dart.git","ssh_url":"git@github.com:eloypastor/polymer-dart.git","clone_url":"https://github.com/eloypastor/polymer-dart.git","svn_url":"https://github.com/eloypastor/polymer-dart","homepage":"https://pub.dartlang.org/packages/polymer","size":3640,"stargazers_count":0,"watchers_count":0,"language":"Dart","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"dart-lang:1.0.0-rc.9","ref":"1.0.0-rc.9","sha":"409e90a71747369f88bf005871340d89235cec5f","user":{"login":"dart-lang","id":1609975,"avatar_url":"https://avatars.githubusercontent.com/u/1609975?v=3","gravatar_id":"","url":"https://api.github.com/users/dart-lang","html_url":"https://github.com/dart-lang","followers_url":"https://api.github.com/users/dart-lang/followers","following_url":"https://api.github.com/users/dart-lang/following{/other_user}","gists_url":"https://api.github.com/users/dart-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/dart-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dart-lang/subscriptions","organizations_url":"https://api.github.com/users/dart-lang/orgs","repos_url":"https://api.github.com/users/dart-lang/repos","events_url":"https://api.github.com/users/dart-lang/events{/privacy}","received_events_url":"https://api.github.com/users/dart-lang/received_events","type":"Organization","site_admin":false},"repo":{"id":24337873,"name":"polymer-dart","full_name":"dart-lang/polymer-dart","owner":{"login":"dart-lang","id":1609975,"avatar_url":"https://avatars.githubusercontent.com/u/1609975?v=3","gravatar_id":"","url":"https://api.github.com/users/dart-lang","html_url":"https://github.com/dart-lang","followers_url":"https://api.github.com/users/dart-lang/followers","following_url":"https://api.github.com/users/dart-lang/following{/other_user}","gists_url":"https://api.github.com/users/dart-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/dart-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dart-lang/subscriptions","organizations_url":"https://api.github.com/users/dart-lang/orgs","repos_url":"https://api.github.com/users/dart-lang/repos","events_url":"https://api.github.com/users/dart-lang/events{/privacy}","received_events_url":"https://api.github.com/users/dart-lang/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dart-lang/polymer-dart","description":"Polymer support for Dart","fork":false,"url":"https://api.github.com/repos/dart-lang/polymer-dart","forks_url":"https://api.github.com/repos/dart-lang/polymer-dart/forks","keys_url":"https://api.github.com/repos/dart-lang/polymer-dart/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dart-lang/polymer-dart/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dart-lang/polymer-dart/teams","hooks_url":"https://api.github.com/repos/dart-lang/polymer-dart/hooks","issue_events_url":"https://api.github.com/repos/dart-lang/polymer-dart/issues/events{/number}","events_url":"https://api.github.com/repos/dart-lang/polymer-dart/events","assignees_url":"https://api.github.com/repos/dart-lang/polymer-dart/assignees{/user}","branches_url":"https://api.github.com/repos/dart-lang/polymer-dart/branches{/branch}","tags_url":"https://api.github.com/repos/dart-lang/polymer-dart/tags","blobs_url":"https://api.github.com/repos/dart-lang/polymer-dart/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dart-lang/polymer-dart/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dart-lang/polymer-dart/git/refs{/sha}","trees_url":"https://api.github.com/repos/dart-lang/polymer-dart/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dart-lang/polymer-dart/statuses/{sha}","languages_url":"https://api.github.com/repos/dart-lang/polymer-dart/languages","stargazers_url":"https://api.github.com/repos/dart-lang/polymer-dart/stargazers","contributors_url":"https://api.github.com/repos/dart-lang/polymer-dart/contributors","subscribers_url":"https://api.github.com/repos/dart-lang/polymer-dart/subscribers","subscription_url":"https://api.github.com/repos/dart-lang/polymer-dart/subscription","commits_url":"https://api.github.com/repos/dart-lang/polymer-dart/commits{/sha}","git_commits_url":"https://api.github.com/repos/dart-lang/polymer-dart/git/commits{/sha}","comments_url":"https://api.github.com/repos/dart-lang/polymer-dart/comments{/number}","issue_comment_url":"https://api.github.com/repos/dart-lang/polymer-dart/issues/comments{/number}","contents_url":"https://api.github.com/repos/dart-lang/polymer-dart/contents/{+path}","compare_url":"https://api.github.com/repos/dart-lang/polymer-dart/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dart-lang/polymer-dart/merges","archive_url":"https://api.github.com/repos/dart-lang/polymer-dart/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dart-lang/polymer-dart/downloads","issues_url":"https://api.github.com/repos/dart-lang/polymer-dart/issues{/number}","pulls_url":"https://api.github.com/repos/dart-lang/polymer-dart/pulls{/number}","milestones_url":"https://api.github.com/repos/dart-lang/polymer-dart/milestones{/number}","notifications_url":"https://api.github.com/repos/dart-lang/polymer-dart/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dart-lang/polymer-dart/labels{/name}","releases_url":"https://api.github.com/repos/dart-lang/polymer-dart/releases{/id}","created_at":"2014-09-22T17:18:57Z","updated_at":"2015-12-03T11:00:51Z","pushed_at":"2015-12-03T15:07:06Z","git_url":"git://github.com/dart-lang/polymer-dart.git","ssh_url":"git@github.com:dart-lang/polymer-dart.git","clone_url":"https://github.com/dart-lang/polymer-dart.git","svn_url":"https://github.com/dart-lang/polymer-dart","homepage":"https://pub.dartlang.org/packages/polymer","size":3700,"stargazers_count":124,"watchers_count":124,"language":"Dart","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":25,"mirror_url":null,"open_issues_count":221,"forks":25,"open_issues":221,"watchers":124,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dart-lang/polymer-dart/pulls/657"},"html":{"href":"https://github.com/dart-lang/polymer-dart/pull/657"},"issue":{"href":"https://api.github.com/repos/dart-lang/polymer-dart/issues/657"},"comments":{"href":"https://api.github.com/repos/dart-lang/polymer-dart/issues/657/comments"},"review_comments":{"href":"https://api.github.com/repos/dart-lang/polymer-dart/pulls/657/comments"},"review_comment":{"href":"https://api.github.com/repos/dart-lang/polymer-dart/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dart-lang/polymer-dart/pulls/657/commits"},"statuses":{"href":"https://api.github.com/repos/dart-lang/polymer-dart/statuses/79bd4f534a28b12fcac02d866870a9b5c5d3bd9d"}}}}