{"action":"created","comment":{"url":"https://api.github.com/repos/nodejs/node/pulls/comments/89308190","pull_request_review_id":9853414,"id":89308190,"diff_hunk":"@@ -0,0 +1,133 @@\n+#include \"node_debug_options.h\"\n+\n+#include <string.h>\n+#include \"util.h\"\n+\n+namespace node {\n+\n+namespace {\n+const int default_debugger_port = 5858;\n+const int default_inspector_port = 9229;\n+\n+}  // namespace\n+\n+DebugOptions::DebugOptions() : debug_enabled_(false),\n+#if HAVE_INSPECTOR\n+                               inspector_enabled_(false),\n+#endif  // HAVE_INSPECTOR\n+                               wait_connect_(false), http_enabled_(false),\n+                               host_name_(\"127.0.0.1\"), port_(-1) { }\n+\n+void DebugOptions::EnableDebugAgent(DebugAgentType tool) {\n+  switch (tool) {\n+#if HAVE_INSPECTOR\n+    case DebugAgentType::kInspector:\n+      inspector_enabled_ = true;\n+      debug_enabled_ = true;\n+      break;\n+#endif  // HAVE_INSPECTOR\n+    case DebugAgentType::kDebugger:\n+      debug_enabled_ = true;\n+      break;\n+    case DebugAgentType::kNone:\n+      break;\n+  }\n+}\n+\n+bool DebugOptions::ParseOption(const std::string& option) {\n+  bool enable_inspector = false;\n+  bool has_argument = false;\n+  std::string option_name;\n+  std::string port;\n+\n+  auto pos = option.find(\"=\");\n+  if (pos != std::string::npos) {\n+    has_argument = true;\n+    option_name = option.substr(0, pos);\n+    port = option.substr(pos + 1);\n+  } else {\n+    option_name = option;\n+  }\n+\n+  if (option_name == \"--debug\") {\n+    debug_enabled_ = true;\n+  } else if (option_name == \"--debug-brk\") {\n+    debug_enabled_ = true;\n+    wait_connect_ = true;\n+  } else if (option_name == \"--debug-port\" && has_argument) {\n+    // Do nothing - argument will be parsed below\n+  // Specifying both --inspect and --debug means debugging is on, using Chromium\n+  // inspector.\n+  } else if (option_name == \"--inspect\") {\n+    debug_enabled_ = true;\n+    enable_inspector = true;\n+  } else {\n+    return false;\n+  }\n+\n+  if (enable_inspector) {\n+#if HAVE_INSPECTOR\n+    inspector_enabled_ = true;\n+#else\n+    fprintf(stderr,\n+            \"Inspector support is not available with this Node.js build\\n\");\n+    return false;\n+#endif\n+  }\n+\n+  if (!has_argument) {\n+    return true;\n+  }\n+\n+  // FIXME(bnoordhuis) Move IPv6 address parsing logic to lib/net.js.\n+  // It seems reasonable to support [address]:port notation\n+  // in net.Server#listen() and net.Socket#connect().\n+  const size_t port_len = port.size();\n+  if (port[0] == '[' && port[port_len - 1] == ']') {\n+    host_name_ = port.substr(1, port_len - 2);\n+    return true;\n+  }\n+\n+  auto colon = port.rfind(':');\n+  if (colon == std::string::npos) {\n+    // Either a port number or a host name.  Assume that\n+    // if it's not all decimal digits, it's a host name.\n+    for (char c : port) {\n+      if (c < '0' || c > '9') {\n+        host_name_ = port;\n+        return true;\n+      }\n+    }\n+  } else {\n+    const int skip =\n+        (colon > 0 && port[0] == '[' && port[colon - 1] == ']') ? 1 : 0;","path":"src/node_debug_options.cc","position":103,"original_position":103,"commit_id":"ac82a37f62a423fdf9d426a24048819a1494c763","original_commit_id":"ac82a37f62a423fdf9d426a24048819a1494c763","user":{"login":"bnoordhuis","id":275871,"avatar_url":"https://avatars.githubusercontent.com/u/275871?v=3","gravatar_id":"","url":"https://api.github.com/users/bnoordhuis","html_url":"https://github.com/bnoordhuis","followers_url":"https://api.github.com/users/bnoordhuis/followers","following_url":"https://api.github.com/users/bnoordhuis/following{/other_user}","gists_url":"https://api.github.com/users/bnoordhuis/gists{/gist_id}","starred_url":"https://api.github.com/users/bnoordhuis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bnoordhuis/subscriptions","organizations_url":"https://api.github.com/users/bnoordhuis/orgs","repos_url":"https://api.github.com/users/bnoordhuis/repos","events_url":"https://api.github.com/users/bnoordhuis/events{/privacy}","received_events_url":"https://api.github.com/users/bnoordhuis/received_events","type":"User","site_admin":false},"body":"The ternary is superfluous here, bools decay to ints, and it makes it harder to read, IMO.","created_at":"2016-11-23T12:43:03Z","updated_at":"2016-11-23T12:48:04Z","html_url":"https://github.com/nodejs/node/pull/9691#discussion_r89308190","pull_request_url":"https://api.github.com/repos/nodejs/node/pulls/9691","_links":{"self":{"href":"https://api.github.com/repos/nodejs/node/pulls/comments/89308190"},"html":{"href":"https://github.com/nodejs/node/pull/9691#discussion_r89308190"},"pull_request":{"href":"https://api.github.com/repos/nodejs/node/pulls/9691"}}},"pull_request":{"url":"https://api.github.com/repos/nodejs/node/pulls/9691","id":94462012,"html_url":"https://github.com/nodejs/node/pull/9691","diff_url":"https://github.com/nodejs/node/pull/9691.diff","patch_url":"https://github.com/nodejs/node/pull/9691.patch","issue_url":"https://api.github.com/repos/nodejs/node/issues/9691","number":9691,"state":"open","locked":false,"title":"inspector: move options parsing","user":{"login":"eugeneo","id":287917,"avatar_url":"https://avatars.githubusercontent.com/u/287917?v=3","gravatar_id":"","url":"https://api.github.com/users/eugeneo","html_url":"https://github.com/eugeneo","followers_url":"https://api.github.com/users/eugeneo/followers","following_url":"https://api.github.com/users/eugeneo/following{/other_user}","gists_url":"https://api.github.com/users/eugeneo/gists{/gist_id}","starred_url":"https://api.github.com/users/eugeneo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eugeneo/subscriptions","organizations_url":"https://api.github.com/users/eugeneo/orgs","repos_url":"https://api.github.com/users/eugeneo/repos","events_url":"https://api.github.com/users/eugeneo/events{/privacy}","received_events_url":"https://api.github.com/users/eugeneo/received_events","type":"User","site_admin":false},"body":"<!--\r\nThank you for your pull request. Please review below requirements.\r\n\r\nBug fixes and new features should include tests and possibly benchmarks.\r\n\r\nContributors guide: https://github.com/nodejs/node/blob/master/CONTRIBUTING.md\r\n-->\r\n\r\n##### Checklist\r\n<!-- Remove items that do not apply. For completed items, change [ ] to [x]. -->\r\n\r\n- [x] `make -j8 test` (UNIX), or `vcbuild test nosign` (Windows) passes\r\n- [x] commit message follows commit guidelines\r\n\r\n##### Affected core subsystem(s)\r\ninspector, core - some code was copied from the core to the inspector.\r\n\r\n##### Description of change\r\n<!-- Provide a description of the change below this comment. -->\r\n\r\nAs inspector functionality expands, more options will need to be added.\r\nCurrently this requires changing adding function arguments, etc. This\r\nchange packs the veriables into a single class that can be extended\r\nwithout changing APIs.","created_at":"2016-11-19T00:50:33Z","updated_at":"2016-11-23T12:48:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9ba179158b85bb4c79b622652c273a647cd8e726","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/nodejs/node/pulls/9691/commits","review_comments_url":"https://api.github.com/repos/nodejs/node/pulls/9691/comments","review_comment_url":"https://api.github.com/repos/nodejs/node/pulls/comments{/number}","comments_url":"https://api.github.com/repos/nodejs/node/issues/9691/comments","statuses_url":"https://api.github.com/repos/nodejs/node/statuses/ac82a37f62a423fdf9d426a24048819a1494c763","head":{"label":"eugeneo:args","ref":"args","sha":"ac82a37f62a423fdf9d426a24048819a1494c763","user":{"login":"eugeneo","id":287917,"avatar_url":"https://avatars.githubusercontent.com/u/287917?v=3","gravatar_id":"","url":"https://api.github.com/users/eugeneo","html_url":"https://github.com/eugeneo","followers_url":"https://api.github.com/users/eugeneo/followers","following_url":"https://api.github.com/users/eugeneo/following{/other_user}","gists_url":"https://api.github.com/users/eugeneo/gists{/gist_id}","starred_url":"https://api.github.com/users/eugeneo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eugeneo/subscriptions","organizations_url":"https://api.github.com/users/eugeneo/orgs","repos_url":"https://api.github.com/users/eugeneo/repos","events_url":"https://api.github.com/users/eugeneo/events{/privacy}","received_events_url":"https://api.github.com/users/eugeneo/received_events","type":"User","site_admin":false},"repo":{"id":54138097,"name":"node","full_name":"eugeneo/node","owner":{"login":"eugeneo","id":287917,"avatar_url":"https://avatars.githubusercontent.com/u/287917?v=3","gravatar_id":"","url":"https://api.github.com/users/eugeneo","html_url":"https://github.com/eugeneo","followers_url":"https://api.github.com/users/eugeneo/followers","following_url":"https://api.github.com/users/eugeneo/following{/other_user}","gists_url":"https://api.github.com/users/eugeneo/gists{/gist_id}","starred_url":"https://api.github.com/users/eugeneo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eugeneo/subscriptions","organizations_url":"https://api.github.com/users/eugeneo/orgs","repos_url":"https://api.github.com/users/eugeneo/repos","events_url":"https://api.github.com/users/eugeneo/events{/privacy}","received_events_url":"https://api.github.com/users/eugeneo/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/eugeneo/node","description":"Node.js JavaScript runtime :sparkles::turtle::rocket::sparkles:","fork":true,"url":"https://api.github.com/repos/eugeneo/node","forks_url":"https://api.github.com/repos/eugeneo/node/forks","keys_url":"https://api.github.com/repos/eugeneo/node/keys{/key_id}","collaborators_url":"https://api.github.com/repos/eugeneo/node/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/eugeneo/node/teams","hooks_url":"https://api.github.com/repos/eugeneo/node/hooks","issue_events_url":"https://api.github.com/repos/eugeneo/node/issues/events{/number}","events_url":"https://api.github.com/repos/eugeneo/node/events","assignees_url":"https://api.github.com/repos/eugeneo/node/assignees{/user}","branches_url":"https://api.github.com/repos/eugeneo/node/branches{/branch}","tags_url":"https://api.github.com/repos/eugeneo/node/tags","blobs_url":"https://api.github.com/repos/eugeneo/node/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/eugeneo/node/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/eugeneo/node/git/refs{/sha}","trees_url":"https://api.github.com/repos/eugeneo/node/git/trees{/sha}","statuses_url":"https://api.github.com/repos/eugeneo/node/statuses/{sha}","languages_url":"https://api.github.com/repos/eugeneo/node/languages","stargazers_url":"https://api.github.com/repos/eugeneo/node/stargazers","contributors_url":"https://api.github.com/repos/eugeneo/node/contributors","subscribers_url":"https://api.github.com/repos/eugeneo/node/subscribers","subscription_url":"https://api.github.com/repos/eugeneo/node/subscription","commits_url":"https://api.github.com/repos/eugeneo/node/commits{/sha}","git_commits_url":"https://api.github.com/repos/eugeneo/node/git/commits{/sha}","comments_url":"https://api.github.com/repos/eugeneo/node/comments{/number}","issue_comment_url":"https://api.github.com/repos/eugeneo/node/issues/comments{/number}","contents_url":"https://api.github.com/repos/eugeneo/node/contents/{+path}","compare_url":"https://api.github.com/repos/eugeneo/node/compare/{base}...{head}","merges_url":"https://api.github.com/repos/eugeneo/node/merges","archive_url":"https://api.github.com/repos/eugeneo/node/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/eugeneo/node/downloads","issues_url":"https://api.github.com/repos/eugeneo/node/issues{/number}","pulls_url":"https://api.github.com/repos/eugeneo/node/pulls{/number}","milestones_url":"https://api.github.com/repos/eugeneo/node/milestones{/number}","notifications_url":"https://api.github.com/repos/eugeneo/node/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/eugeneo/node/labels{/name}","releases_url":"https://api.github.com/repos/eugeneo/node/releases{/id}","deployments_url":"https://api.github.com/repos/eugeneo/node/deployments","created_at":"2016-03-17T17:30:32Z","updated_at":"2016-04-18T17:50:02Z","pushed_at":"2016-11-22T22:48:32Z","git_url":"git://github.com/eugeneo/node.git","ssh_url":"git@github.com:eugeneo/node.git","clone_url":"https://github.com/eugeneo/node.git","svn_url":"https://github.com/eugeneo/node","homepage":"https://nodejs.org","size":234547,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":4,"forks":0,"open_issues":4,"watchers":0,"default_branch":"autoroll"}},"base":{"label":"nodejs:master","ref":"master","sha":"3cbb553df8fefbed7fd09b4b75f1d6f7b611d3b5","user":{"login":"nodejs","id":9950313,"avatar_url":"https://avatars.githubusercontent.com/u/9950313?v=3","gravatar_id":"","url":"https://api.github.com/users/nodejs","html_url":"https://github.com/nodejs","followers_url":"https://api.github.com/users/nodejs/followers","following_url":"https://api.github.com/users/nodejs/following{/other_user}","gists_url":"https://api.github.com/users/nodejs/gists{/gist_id}","starred_url":"https://api.github.com/users/nodejs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nodejs/subscriptions","organizations_url":"https://api.github.com/users/nodejs/orgs","repos_url":"https://api.github.com/users/nodejs/repos","events_url":"https://api.github.com/users/nodejs/events{/privacy}","received_events_url":"https://api.github.com/users/nodejs/received_events","type":"Organization","site_admin":false},"repo":{"id":27193779,"name":"node","full_name":"nodejs/node","owner":{"login":"nodejs","id":9950313,"avatar_url":"https://avatars.githubusercontent.com/u/9950313?v=3","gravatar_id":"","url":"https://api.github.com/users/nodejs","html_url":"https://github.com/nodejs","followers_url":"https://api.github.com/users/nodejs/followers","following_url":"https://api.github.com/users/nodejs/following{/other_user}","gists_url":"https://api.github.com/users/nodejs/gists{/gist_id}","starred_url":"https://api.github.com/users/nodejs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nodejs/subscriptions","organizations_url":"https://api.github.com/users/nodejs/orgs","repos_url":"https://api.github.com/users/nodejs/repos","events_url":"https://api.github.com/users/nodejs/events{/privacy}","received_events_url":"https://api.github.com/users/nodejs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/nodejs/node","description":"Node.js JavaScript runtime :sparkles::turtle::rocket::sparkles:","fork":false,"url":"https://api.github.com/repos/nodejs/node","forks_url":"https://api.github.com/repos/nodejs/node/forks","keys_url":"https://api.github.com/repos/nodejs/node/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nodejs/node/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nodejs/node/teams","hooks_url":"https://api.github.com/repos/nodejs/node/hooks","issue_events_url":"https://api.github.com/repos/nodejs/node/issues/events{/number}","events_url":"https://api.github.com/repos/nodejs/node/events","assignees_url":"https://api.github.com/repos/nodejs/node/assignees{/user}","branches_url":"https://api.github.com/repos/nodejs/node/branches{/branch}","tags_url":"https://api.github.com/repos/nodejs/node/tags","blobs_url":"https://api.github.com/repos/nodejs/node/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nodejs/node/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nodejs/node/git/refs{/sha}","trees_url":"https://api.github.com/repos/nodejs/node/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nodejs/node/statuses/{sha}","languages_url":"https://api.github.com/repos/nodejs/node/languages","stargazers_url":"https://api.github.com/repos/nodejs/node/stargazers","contributors_url":"https://api.github.com/repos/nodejs/node/contributors","subscribers_url":"https://api.github.com/repos/nodejs/node/subscribers","subscription_url":"https://api.github.com/repos/nodejs/node/subscription","commits_url":"https://api.github.com/repos/nodejs/node/commits{/sha}","git_commits_url":"https://api.github.com/repos/nodejs/node/git/commits{/sha}","comments_url":"https://api.github.com/repos/nodejs/node/comments{/number}","issue_comment_url":"https://api.github.com/repos/nodejs/node/issues/comments{/number}","contents_url":"https://api.github.com/repos/nodejs/node/contents/{+path}","compare_url":"https://api.github.com/repos/nodejs/node/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nodejs/node/merges","archive_url":"https://api.github.com/repos/nodejs/node/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nodejs/node/downloads","issues_url":"https://api.github.com/repos/nodejs/node/issues{/number}","pulls_url":"https://api.github.com/repos/nodejs/node/pulls{/number}","milestones_url":"https://api.github.com/repos/nodejs/node/milestones{/number}","notifications_url":"https://api.github.com/repos/nodejs/node/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nodejs/node/labels{/name}","releases_url":"https://api.github.com/repos/nodejs/node/releases{/id}","deployments_url":"https://api.github.com/repos/nodejs/node/deployments","created_at":"2014-11-26T19:57:11Z","updated_at":"2016-11-23T12:45:01Z","pushed_at":"2016-11-23T11:52:52Z","git_url":"git://github.com/nodejs/node.git","ssh_url":"git@github.com:nodejs/node.git","clone_url":"https://github.com/nodejs/node.git","svn_url":"https://github.com/nodejs/node","homepage":"https://nodejs.org","size":367955,"stargazers_count":29146,"watchers_count":29146,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5024,"mirror_url":null,"open_issues_count":943,"forks":5024,"open_issues":943,"watchers":29146,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/nodejs/node/pulls/9691"},"html":{"href":"https://github.com/nodejs/node/pull/9691"},"issue":{"href":"https://api.github.com/repos/nodejs/node/issues/9691"},"comments":{"href":"https://api.github.com/repos/nodejs/node/issues/9691/comments"},"review_comments":{"href":"https://api.github.com/repos/nodejs/node/pulls/9691/comments"},"review_comment":{"href":"https://api.github.com/repos/nodejs/node/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/nodejs/node/pulls/9691/commits"},"statuses":{"href":"https://api.github.com/repos/nodejs/node/statuses/ac82a37f62a423fdf9d426a24048819a1494c763"}}}}
{"actor":{"display_login":"bnoordhuis"}}