{"action":"created","comment":{"url":"https://api.github.com/repos/metarhia/JSTP/pulls/comments/109512346","pull_request_review_id":30619768,"id":109512346,"diff_hunk":"@@ -0,0 +1,190 @@\n+#!/usr/bin/env node\n+\n+'use strict';\n+\n+// TODO: support jstp://server and jstps://server\n+\n+const jstp = require('.');\n+const readline = require('readline');\n+\n+const commandProcessor = {};\n+const lineProcessor = {};\n+\n+const rl = readline.createInterface({\n+  input: process.stdin,\n+  output: process.stdout,\n+  completer\n+});\n+\n+const log = msg => {\n+  const userInput = rl.line;\n+  if (userInput) rl.clearLine();\n+  console.log(msg);\n+  rl.write('\\n');\n+  if (userInput) rl.write(userInput);\n+};\n+\n+rl.on('line', (line) => {\n+  const [type, leftover] = _split(line.trim(), ' ', 1);\n+  if (!type) {\n+    return rl.prompt(true);\n+  }\n+  const processor = lineProcessor[type];\n+  if (!processor) {\n+    log(`Unknown command ${type}`);\n+  } else {\n+    processor(leftover, (err, result) => {\n+      if (err) return log(`${err.name} occurred: ${err.message}`);\n+      log(result);\n+    });\n+    rl.prompt(true);\n+  }\n+});\n+\n+rl.on('SIGINT', () => {\n+  rl.close();\n+  process.exit();\n+});\n+\n+rl.on('close', () => {\n+  process.exit();\n+});\n+\n+function completer(line) {\n+  return [[], line];\n+}\n+\n+const state = {\n+  client: null,\n+  connection: null\n+};\n+\n+commandProcessor.call = (interfaceName, methodName, args, callback) => {\n+  if (state.client === null) return callback(new Error('Not connected'));\n+  state.connection.callMethod(interfaceName, methodName, args, callback);\n+};\n+\n+commandProcessor.event = (interfaceName, eventName, args, callback) => {\n+  if (state.client === null) return callback(new Error('Not connected'));\n+  state.connection.emitRemoteEvent(interfaceName, eventName, args);\n+  callback();\n+};\n+\n+commandProcessor.connect = (host, port, appName, callback) => {\n+  state.client = jstp.tcp.createClient({ host, port, secure: true });\n+  state.client.connectAndHandshake(appName, null, null,\n+      (err, connection) => {\n+        if (err) return callback(err);\n+        state.connection = connection;\n+        // todo make event registering generic\n+        connection.on('event', (data) => {\n+          log(`Received remote event: ${jstp.stringify(data)}`);\n+        });\n+        callback();\n+      });\n+};\n+\n+commandProcessor.disconnect = (callback) => {\n+  if (state.client !== null) {","path":"tools/cli.js","position":88,"original_position":88,"commit_id":"a6145a93ef6b12dabb670b3f77d02f397a656efe","original_commit_id":"a6145a93ef6b12dabb670b3f77d02f397a656efe","user":{"login":"lundibundi","id":9109612,"avatar_url":"https://avatars3.githubusercontent.com/u/9109612?v=3","gravatar_id":"","url":"https://api.github.com/users/lundibundi","html_url":"https://github.com/lundibundi","followers_url":"https://api.github.com/users/lundibundi/followers","following_url":"https://api.github.com/users/lundibundi/following{/other_user}","gists_url":"https://api.github.com/users/lundibundi/gists{/gist_id}","starred_url":"https://api.github.com/users/lundibundi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lundibundi/subscriptions","organizations_url":"https://api.github.com/users/lundibundi/orgs","repos_url":"https://api.github.com/users/lundibundi/repos","events_url":"https://api.github.com/users/lundibundi/events{/privacy}","received_events_url":"https://api.github.com/users/lundibundi/received_events","type":"User","site_admin":false},"body":"sure","created_at":"2017-04-03T20:10:28Z","updated_at":"2017-04-03T20:10:28Z","html_url":"https://github.com/metarhia/JSTP/pull/107#discussion_r109512346","pull_request_url":"https://api.github.com/repos/metarhia/JSTP/pulls/107","_links":{"self":{"href":"https://api.github.com/repos/metarhia/JSTP/pulls/comments/109512346"},"html":{"href":"https://github.com/metarhia/JSTP/pull/107#discussion_r109512346"},"pull_request":{"href":"https://api.github.com/repos/metarhia/JSTP/pulls/107"}}},"pull_request":{"url":"https://api.github.com/repos/metarhia/JSTP/pulls/107","id":113018182,"html_url":"https://github.com/metarhia/JSTP/pull/107","diff_url":"https://github.com/metarhia/JSTP/pull/107.diff","patch_url":"https://github.com/metarhia/JSTP/pull/107.patch","issue_url":"https://api.github.com/repos/metarhia/JSTP/issues/107","number":107,"state":"open","locked":false,"title":"Bring belochub/jstp-cli upstream","user":{"login":"aqrln","id":4923335,"avatar_url":"https://avatars2.githubusercontent.com/u/4923335?v=3","gravatar_id":"","url":"https://api.github.com/users/aqrln","html_url":"https://github.com/aqrln","followers_url":"https://api.github.com/users/aqrln/followers","following_url":"https://api.github.com/users/aqrln/following{/other_user}","gists_url":"https://api.github.com/users/aqrln/gists{/gist_id}","starred_url":"https://api.github.com/users/aqrln/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aqrln/subscriptions","organizations_url":"https://api.github.com/users/aqrln/orgs","repos_url":"https://api.github.com/users/aqrln/repos","events_url":"https://api.github.com/users/aqrln/events{/privacy}","received_events_url":"https://api.github.com/users/aqrln/received_events","type":"User","site_admin":false},"body":"I've created a [branch](https://github.com/metarhia/JSTP/tree/cli) to port [belochub/jstp-cli](https://github.com/belochub/jstp-cli/) to be a part of JSTP itself, as it was agreed upon in https://github.com/belochub/jstp-cli/issues/1.\r\n\r\nRight now `cli.js` is located in the root of the project in order to mirror the original repo and make cherry-picking new commits effortless. It should later be separated into `bin/cli.js` and `lib/cli/*.js`.\r\n\r\n/cc @belochub @lundibundi ","created_at":"2017-03-28T16:55:51Z","updated_at":"2017-04-03T20:10:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"be1cc9b838bfc558fee19886b59b94b6687e74ef","assignee":{"login":"belochub","id":3501391,"avatar_url":"https://avatars2.githubusercontent.com/u/3501391?v=3","gravatar_id":"","url":"https://api.github.com/users/belochub","html_url":"https://github.com/belochub","followers_url":"https://api.github.com/users/belochub/followers","following_url":"https://api.github.com/users/belochub/following{/other_user}","gists_url":"https://api.github.com/users/belochub/gists{/gist_id}","starred_url":"https://api.github.com/users/belochub/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/belochub/subscriptions","organizations_url":"https://api.github.com/users/belochub/orgs","repos_url":"https://api.github.com/users/belochub/repos","events_url":"https://api.github.com/users/belochub/events{/privacy}","received_events_url":"https://api.github.com/users/belochub/received_events","type":"User","site_admin":false},"assignees":[{"login":"belochub","id":3501391,"avatar_url":"https://avatars2.githubusercontent.com/u/3501391?v=3","gravatar_id":"","url":"https://api.github.com/users/belochub","html_url":"https://github.com/belochub","followers_url":"https://api.github.com/users/belochub/followers","following_url":"https://api.github.com/users/belochub/following{/other_user}","gists_url":"https://api.github.com/users/belochub/gists{/gist_id}","starred_url":"https://api.github.com/users/belochub/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/belochub/subscriptions","organizations_url":"https://api.github.com/users/belochub/orgs","repos_url":"https://api.github.com/users/belochub/repos","events_url":"https://api.github.com/users/belochub/events{/privacy}","received_events_url":"https://api.github.com/users/belochub/received_events","type":"User","site_admin":false},{"login":"aqrln","id":4923335,"avatar_url":"https://avatars2.githubusercontent.com/u/4923335?v=3","gravatar_id":"","url":"https://api.github.com/users/aqrln","html_url":"https://github.com/aqrln","followers_url":"https://api.github.com/users/aqrln/followers","following_url":"https://api.github.com/users/aqrln/following{/other_user}","gists_url":"https://api.github.com/users/aqrln/gists{/gist_id}","starred_url":"https://api.github.com/users/aqrln/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aqrln/subscriptions","organizations_url":"https://api.github.com/users/aqrln/orgs","repos_url":"https://api.github.com/users/aqrln/repos","events_url":"https://api.github.com/users/aqrln/events{/privacy}","received_events_url":"https://api.github.com/users/aqrln/received_events","type":"User","site_admin":false},{"login":"lundibundi","id":9109612,"avatar_url":"https://avatars3.githubusercontent.com/u/9109612?v=3","gravatar_id":"","url":"https://api.github.com/users/lundibundi","html_url":"https://github.com/lundibundi","followers_url":"https://api.github.com/users/lundibundi/followers","following_url":"https://api.github.com/users/lundibundi/following{/other_user}","gists_url":"https://api.github.com/users/lundibundi/gists{/gist_id}","starred_url":"https://api.github.com/users/lundibundi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lundibundi/subscriptions","organizations_url":"https://api.github.com/users/lundibundi/orgs","repos_url":"https://api.github.com/users/lundibundi/repos","events_url":"https://api.github.com/users/lundibundi/events{/privacy}","received_events_url":"https://api.github.com/users/lundibundi/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/metarhia/JSTP/pulls/107/commits","review_comments_url":"https://api.github.com/repos/metarhia/JSTP/pulls/107/comments","review_comment_url":"https://api.github.com/repos/metarhia/JSTP/pulls/comments{/number}","comments_url":"https://api.github.com/repos/metarhia/JSTP/issues/107/comments","statuses_url":"https://api.github.com/repos/metarhia/JSTP/statuses/a6145a93ef6b12dabb670b3f77d02f397a656efe","head":{"label":"metarhia:cli","ref":"cli","sha":"a6145a93ef6b12dabb670b3f77d02f397a656efe","user":{"login":"metarhia","id":18060695,"avatar_url":"https://avatars1.githubusercontent.com/u/18060695?v=3","gravatar_id":"","url":"https://api.github.com/users/metarhia","html_url":"https://github.com/metarhia","followers_url":"https://api.github.com/users/metarhia/followers","following_url":"https://api.github.com/users/metarhia/following{/other_user}","gists_url":"https://api.github.com/users/metarhia/gists{/gist_id}","starred_url":"https://api.github.com/users/metarhia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/metarhia/subscriptions","organizations_url":"https://api.github.com/users/metarhia/orgs","repos_url":"https://api.github.com/users/metarhia/repos","events_url":"https://api.github.com/users/metarhia/events{/privacy}","received_events_url":"https://api.github.com/users/metarhia/received_events","type":"Organization","site_admin":false},"repo":{"id":53201312,"name":"JSTP","full_name":"metarhia/JSTP","owner":{"login":"metarhia","id":18060695,"avatar_url":"https://avatars1.githubusercontent.com/u/18060695?v=3","gravatar_id":"","url":"https://api.github.com/users/metarhia","html_url":"https://github.com/metarhia","followers_url":"https://api.github.com/users/metarhia/followers","following_url":"https://api.github.com/users/metarhia/following{/other_user}","gists_url":"https://api.github.com/users/metarhia/gists{/gist_id}","starred_url":"https://api.github.com/users/metarhia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/metarhia/subscriptions","organizations_url":"https://api.github.com/users/metarhia/orgs","repos_url":"https://api.github.com/users/metarhia/repos","events_url":"https://api.github.com/users/metarhia/events{/privacy}","received_events_url":"https://api.github.com/users/metarhia/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/metarhia/JSTP","description":"JavaScript Transfer Protocol","fork":false,"url":"https://api.github.com/repos/metarhia/JSTP","forks_url":"https://api.github.com/repos/metarhia/JSTP/forks","keys_url":"https://api.github.com/repos/metarhia/JSTP/keys{/key_id}","collaborators_url":"https://api.github.com/repos/metarhia/JSTP/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/metarhia/JSTP/teams","hooks_url":"https://api.github.com/repos/metarhia/JSTP/hooks","issue_events_url":"https://api.github.com/repos/metarhia/JSTP/issues/events{/number}","events_url":"https://api.github.com/repos/metarhia/JSTP/events","assignees_url":"https://api.github.com/repos/metarhia/JSTP/assignees{/user}","branches_url":"https://api.github.com/repos/metarhia/JSTP/branches{/branch}","tags_url":"https://api.github.com/repos/metarhia/JSTP/tags","blobs_url":"https://api.github.com/repos/metarhia/JSTP/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/metarhia/JSTP/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/metarhia/JSTP/git/refs{/sha}","trees_url":"https://api.github.com/repos/metarhia/JSTP/git/trees{/sha}","statuses_url":"https://api.github.com/repos/metarhia/JSTP/statuses/{sha}","languages_url":"https://api.github.com/repos/metarhia/JSTP/languages","stargazers_url":"https://api.github.com/repos/metarhia/JSTP/stargazers","contributors_url":"https://api.github.com/repos/metarhia/JSTP/contributors","subscribers_url":"https://api.github.com/repos/metarhia/JSTP/subscribers","subscription_url":"https://api.github.com/repos/metarhia/JSTP/subscription","commits_url":"https://api.github.com/repos/metarhia/JSTP/commits{/sha}","git_commits_url":"https://api.github.com/repos/metarhia/JSTP/git/commits{/sha}","comments_url":"https://api.github.com/repos/metarhia/JSTP/comments{/number}","issue_comment_url":"https://api.github.com/repos/metarhia/JSTP/issues/comments{/number}","contents_url":"https://api.github.com/repos/metarhia/JSTP/contents/{+path}","compare_url":"https://api.github.com/repos/metarhia/JSTP/compare/{base}...{head}","merges_url":"https://api.github.com/repos/metarhia/JSTP/merges","archive_url":"https://api.github.com/repos/metarhia/JSTP/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/metarhia/JSTP/downloads","issues_url":"https://api.github.com/repos/metarhia/JSTP/issues{/number}","pulls_url":"https://api.github.com/repos/metarhia/JSTP/pulls{/number}","milestones_url":"https://api.github.com/repos/metarhia/JSTP/milestones{/number}","notifications_url":"https://api.github.com/repos/metarhia/JSTP/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/metarhia/JSTP/labels{/name}","releases_url":"https://api.github.com/repos/metarhia/JSTP/releases{/id}","deployments_url":"https://api.github.com/repos/metarhia/JSTP/deployments","created_at":"2016-03-05T12:55:44Z","updated_at":"2017-03-18T17:31:10Z","pushed_at":"2017-04-03T19:40:43Z","git_url":"git://github.com/metarhia/JSTP.git","ssh_url":"git@github.com:metarhia/JSTP.git","clone_url":"https://github.com/metarhia/JSTP.git","svn_url":"https://github.com/metarhia/JSTP","homepage":null,"size":1727,"stargazers_count":32,"watchers_count":32,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1,"mirror_url":null,"open_issues_count":22,"forks":1,"open_issues":22,"watchers":32,"default_branch":"master"}},"base":{"label":"metarhia:master","ref":"master","sha":"fa7a7036d0dfd00539b98a944b9c7e43010a2e30","user":{"login":"metarhia","id":18060695,"avatar_url":"https://avatars1.githubusercontent.com/u/18060695?v=3","gravatar_id":"","url":"https://api.github.com/users/metarhia","html_url":"https://github.com/metarhia","followers_url":"https://api.github.com/users/metarhia/followers","following_url":"https://api.github.com/users/metarhia/following{/other_user}","gists_url":"https://api.github.com/users/metarhia/gists{/gist_id}","starred_url":"https://api.github.com/users/metarhia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/metarhia/subscriptions","organizations_url":"https://api.github.com/users/metarhia/orgs","repos_url":"https://api.github.com/users/metarhia/repos","events_url":"https://api.github.com/users/metarhia/events{/privacy}","received_events_url":"https://api.github.com/users/metarhia/received_events","type":"Organization","site_admin":false},"repo":{"id":53201312,"name":"JSTP","full_name":"metarhia/JSTP","owner":{"login":"metarhia","id":18060695,"avatar_url":"https://avatars1.githubusercontent.com/u/18060695?v=3","gravatar_id":"","url":"https://api.github.com/users/metarhia","html_url":"https://github.com/metarhia","followers_url":"https://api.github.com/users/metarhia/followers","following_url":"https://api.github.com/users/metarhia/following{/other_user}","gists_url":"https://api.github.com/users/metarhia/gists{/gist_id}","starred_url":"https://api.github.com/users/metarhia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/metarhia/subscriptions","organizations_url":"https://api.github.com/users/metarhia/orgs","repos_url":"https://api.github.com/users/metarhia/repos","events_url":"https://api.github.com/users/metarhia/events{/privacy}","received_events_url":"https://api.github.com/users/metarhia/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/metarhia/JSTP","description":"JavaScript Transfer Protocol","fork":false,"url":"https://api.github.com/repos/metarhia/JSTP","forks_url":"https://api.github.com/repos/metarhia/JSTP/forks","keys_url":"https://api.github.com/repos/metarhia/JSTP/keys{/key_id}","collaborators_url":"https://api.github.com/repos/metarhia/JSTP/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/metarhia/JSTP/teams","hooks_url":"https://api.github.com/repos/metarhia/JSTP/hooks","issue_events_url":"https://api.github.com/repos/metarhia/JSTP/issues/events{/number}","events_url":"https://api.github.com/repos/metarhia/JSTP/events","assignees_url":"https://api.github.com/repos/metarhia/JSTP/assignees{/user}","branches_url":"https://api.github.com/repos/metarhia/JSTP/branches{/branch}","tags_url":"https://api.github.com/repos/metarhia/JSTP/tags","blobs_url":"https://api.github.com/repos/metarhia/JSTP/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/metarhia/JSTP/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/metarhia/JSTP/git/refs{/sha}","trees_url":"https://api.github.com/repos/metarhia/JSTP/git/trees{/sha}","statuses_url":"https://api.github.com/repos/metarhia/JSTP/statuses/{sha}","languages_url":"https://api.github.com/repos/metarhia/JSTP/languages","stargazers_url":"https://api.github.com/repos/metarhia/JSTP/stargazers","contributors_url":"https://api.github.com/repos/metarhia/JSTP/contributors","subscribers_url":"https://api.github.com/repos/metarhia/JSTP/subscribers","subscription_url":"https://api.github.com/repos/metarhia/JSTP/subscription","commits_url":"https://api.github.com/repos/metarhia/JSTP/commits{/sha}","git_commits_url":"https://api.github.com/repos/metarhia/JSTP/git/commits{/sha}","comments_url":"https://api.github.com/repos/metarhia/JSTP/comments{/number}","issue_comment_url":"https://api.github.com/repos/metarhia/JSTP/issues/comments{/number}","contents_url":"https://api.github.com/repos/metarhia/JSTP/contents/{+path}","compare_url":"https://api.github.com/repos/metarhia/JSTP/compare/{base}...{head}","merges_url":"https://api.github.com/repos/metarhia/JSTP/merges","archive_url":"https://api.github.com/repos/metarhia/JSTP/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/metarhia/JSTP/downloads","issues_url":"https://api.github.com/repos/metarhia/JSTP/issues{/number}","pulls_url":"https://api.github.com/repos/metarhia/JSTP/pulls{/number}","milestones_url":"https://api.github.com/repos/metarhia/JSTP/milestones{/number}","notifications_url":"https://api.github.com/repos/metarhia/JSTP/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/metarhia/JSTP/labels{/name}","releases_url":"https://api.github.com/repos/metarhia/JSTP/releases{/id}","deployments_url":"https://api.github.com/repos/metarhia/JSTP/deployments","created_at":"2016-03-05T12:55:44Z","updated_at":"2017-03-18T17:31:10Z","pushed_at":"2017-04-03T19:40:43Z","git_url":"git://github.com/metarhia/JSTP.git","ssh_url":"git@github.com:metarhia/JSTP.git","clone_url":"https://github.com/metarhia/JSTP.git","svn_url":"https://github.com/metarhia/JSTP","homepage":null,"size":1727,"stargazers_count":32,"watchers_count":32,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1,"mirror_url":null,"open_issues_count":22,"forks":1,"open_issues":22,"watchers":32,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/metarhia/JSTP/pulls/107"},"html":{"href":"https://github.com/metarhia/JSTP/pull/107"},"issue":{"href":"https://api.github.com/repos/metarhia/JSTP/issues/107"},"comments":{"href":"https://api.github.com/repos/metarhia/JSTP/issues/107/comments"},"review_comments":{"href":"https://api.github.com/repos/metarhia/JSTP/pulls/107/comments"},"review_comment":{"href":"https://api.github.com/repos/metarhia/JSTP/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/metarhia/JSTP/pulls/107/commits"},"statuses":{"href":"https://api.github.com/repos/metarhia/JSTP/statuses/a6145a93ef6b12dabb670b3f77d02f397a656efe"}}}}
{"actor":{"display_login":"lundibundi"}}