{"action":"created","comment":{"url":"https://api.github.com/repos/mediachain/aleph/pulls/comments/91748701","pull_request_review_id":12260371,"id":91748701,"diff_hunk":"@@ -23,22 +25,59 @@ module.exports = {\n \n   handler: subcommand((opts: {client: RestClient, objectIds: Array<string>, color: ?boolean, pretty: boolean}) => {\n     const {client, objectIds, color, pretty} = opts\n-    const printObject = objectPrinter(color, pretty)\n+\n+    if (objectIds.length === 1) {\n+      return client.getData(objectIds[0])\n+        .then(objectFormatter(color, pretty))\n+        .then(output => process.stdout.write(output))\n+    }\n+\n     return client.batchGetDataStream(objectIds)\n-      .then(\n-        stream => new Promise((resolve, reject) => {\n-          stream.on('data', printObject)\n-          stream.on('error', reject)\n-          stream.on('end', resolve)\n-        })\n-      )\n+      .then(stream => printStream(stream, objectIds, color, pretty))\n+  })\n+}\n+\n+function printStream (stream: ReadableStream, objectIds: Array<string>, color: ?boolean, pretty: boolean): Promise<void> {\n+  const formatObject = objectFormatter(color, pretty)\n+  const {stdout} = process\n+  stdout.write('{')\n+  if (pretty) {\n+    stdout.write('\\n')\n+  }\n+\n+  return new Promise((resolve, reject) => {\n+    const leftPad = pretty ? '  ' : ''\n+    stream.on('data', result => {\n+      const key = objectIds.pop()\n+      const keyString = formatObject(key).trim()\n+      const formatted = formatObject(result).trim()\n+        .split('\\n')\n+        .map((s, i) => (i === 0) ? s : leftPad + s)\n+        .join('\\n')\n+\n+      stdout.write(`${leftPad}${keyString}: ${formatted}`)\n+      if (objectIds.length > 0) {\n+        stdout.write(',')\n+      }\n+      if (pretty) {\n+        stdout.write('\\n')\n+      }\n+    })\n+    stream.on('error', (err) => {\n+      stdout.write(`}\\n`)\n+      reject(err)\n+    })\n+    stream.on('end', () => {","path":"src/client/cli/commands/data/get.js","position":78,"original_position":70,"commit_id":"f3bee483780445e4451d9df6d1c87a6799981fd9","original_commit_id":"f3bee483780445e4451d9df6d1c87a6799981fd9","user":{"login":"vyzo","id":36426,"avatar_url":"https://avatars.githubusercontent.com/u/36426?v=3","gravatar_id":"","url":"https://api.github.com/users/vyzo","html_url":"https://github.com/vyzo","followers_url":"https://api.github.com/users/vyzo/followers","following_url":"https://api.github.com/users/vyzo/following{/other_user}","gists_url":"https://api.github.com/users/vyzo/gists{/gist_id}","starred_url":"https://api.github.com/users/vyzo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vyzo/subscriptions","organizations_url":"https://api.github.com/users/vyzo/orgs","repos_url":"https://api.github.com/users/vyzo/repos","events_url":"https://api.github.com/users/vyzo/events{/privacy}","received_events_url":"https://api.github.com/users/vyzo/received_events","type":"User","site_admin":false},"body":"this seems unnecessary -- or is the code reused from the data protocol?","created_at":"2016-12-09T16:33:12Z","updated_at":"2016-12-09T16:33:43Z","html_url":"https://github.com/mediachain/aleph/pull/123#discussion_r91748701","pull_request_url":"https://api.github.com/repos/mediachain/aleph/pulls/123","_links":{"self":{"href":"https://api.github.com/repos/mediachain/aleph/pulls/comments/91748701"},"html":{"href":"https://github.com/mediachain/aleph/pull/123#discussion_r91748701"},"pull_request":{"href":"https://api.github.com/repos/mediachain/aleph/pulls/123"}}},"pull_request":{"url":"https://api.github.com/repos/mediachain/aleph/pulls/123","id":97196747,"html_url":"https://github.com/mediachain/aleph/pull/123","diff_url":"https://github.com/mediachain/aleph/pull/123.diff","patch_url":"https://github.com/mediachain/aleph/pull/123.patch","issue_url":"https://api.github.com/repos/mediachain/aleph/issues/123","number":123,"state":"open","locked":false,"title":"Batch data object fetching for mcclient","user":{"login":"yusefnapora","id":678715,"avatar_url":"https://avatars.githubusercontent.com/u/678715?v=3","gravatar_id":"","url":"https://api.github.com/users/yusefnapora","html_url":"https://github.com/yusefnapora","followers_url":"https://api.github.com/users/yusefnapora/followers","following_url":"https://api.github.com/users/yusefnapora/following{/other_user}","gists_url":"https://api.github.com/users/yusefnapora/gists{/gist_id}","starred_url":"https://api.github.com/users/yusefnapora/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yusefnapora/subscriptions","organizations_url":"https://api.github.com/users/yusefnapora/orgs","repos_url":"https://api.github.com/users/yusefnapora/repos","events_url":"https://api.github.com/users/yusefnapora/events{/privacy}","received_events_url":"https://api.github.com/users/yusefnapora/received_events","type":"User","site_admin":false},"body":"Adds support for the batch get support added in https://github.com/mediachain/concat/pull/100\r\n\r\nThe `mcclient data get` command now accepts multiple keys and will fetch them with the batch interface.\r\n\r\nRight now it prints the returned objects directly to the console one after another; I'm torn on whether we should wrap them in an array literal first, so that the entire output would be valid JSON.","created_at":"2016-12-08T20:41:13Z","updated_at":"2016-12-09T16:33:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f53da914009974dceb7fe8b82d8aaa9e4d8e22d6","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/mediachain/aleph/pulls/123/commits","review_comments_url":"https://api.github.com/repos/mediachain/aleph/pulls/123/comments","review_comment_url":"https://api.github.com/repos/mediachain/aleph/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mediachain/aleph/issues/123/comments","statuses_url":"https://api.github.com/repos/mediachain/aleph/statuses/f3bee483780445e4451d9df6d1c87a6799981fd9","head":{"label":"mediachain:yn/mcclient-batch-get","ref":"yn/mcclient-batch-get","sha":"f3bee483780445e4451d9df6d1c87a6799981fd9","user":{"login":"mediachain","id":16711838,"avatar_url":"https://avatars.githubusercontent.com/u/16711838?v=3","gravatar_id":"","url":"https://api.github.com/users/mediachain","html_url":"https://github.com/mediachain","followers_url":"https://api.github.com/users/mediachain/followers","following_url":"https://api.github.com/users/mediachain/following{/other_user}","gists_url":"https://api.github.com/users/mediachain/gists{/gist_id}","starred_url":"https://api.github.com/users/mediachain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mediachain/subscriptions","organizations_url":"https://api.github.com/users/mediachain/orgs","repos_url":"https://api.github.com/users/mediachain/repos","events_url":"https://api.github.com/users/mediachain/events{/privacy}","received_events_url":"https://api.github.com/users/mediachain/received_events","type":"Organization","site_admin":false},"repo":{"id":66977529,"name":"aleph","full_name":"mediachain/aleph","owner":{"login":"mediachain","id":16711838,"avatar_url":"https://avatars.githubusercontent.com/u/16711838?v=3","gravatar_id":"","url":"https://api.github.com/users/mediachain","html_url":"https://github.com/mediachain","followers_url":"https://api.github.com/users/mediachain/followers","following_url":"https://api.github.com/users/mediachain/following{/other_user}","gists_url":"https://api.github.com/users/mediachain/gists{/gist_id}","starred_url":"https://api.github.com/users/mediachain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mediachain/subscriptions","organizations_url":"https://api.github.com/users/mediachain/orgs","repos_url":"https://api.github.com/users/mediachain/repos","events_url":"https://api.github.com/users/mediachain/events{/privacy}","received_events_url":"https://api.github.com/users/mediachain/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mediachain/aleph","description":"א: The mediachain universe manipulation engine","fork":false,"url":"https://api.github.com/repos/mediachain/aleph","forks_url":"https://api.github.com/repos/mediachain/aleph/forks","keys_url":"https://api.github.com/repos/mediachain/aleph/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mediachain/aleph/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mediachain/aleph/teams","hooks_url":"https://api.github.com/repos/mediachain/aleph/hooks","issue_events_url":"https://api.github.com/repos/mediachain/aleph/issues/events{/number}","events_url":"https://api.github.com/repos/mediachain/aleph/events","assignees_url":"https://api.github.com/repos/mediachain/aleph/assignees{/user}","branches_url":"https://api.github.com/repos/mediachain/aleph/branches{/branch}","tags_url":"https://api.github.com/repos/mediachain/aleph/tags","blobs_url":"https://api.github.com/repos/mediachain/aleph/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mediachain/aleph/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mediachain/aleph/git/refs{/sha}","trees_url":"https://api.github.com/repos/mediachain/aleph/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mediachain/aleph/statuses/{sha}","languages_url":"https://api.github.com/repos/mediachain/aleph/languages","stargazers_url":"https://api.github.com/repos/mediachain/aleph/stargazers","contributors_url":"https://api.github.com/repos/mediachain/aleph/contributors","subscribers_url":"https://api.github.com/repos/mediachain/aleph/subscribers","subscription_url":"https://api.github.com/repos/mediachain/aleph/subscription","commits_url":"https://api.github.com/repos/mediachain/aleph/commits{/sha}","git_commits_url":"https://api.github.com/repos/mediachain/aleph/git/commits{/sha}","comments_url":"https://api.github.com/repos/mediachain/aleph/comments{/number}","issue_comment_url":"https://api.github.com/repos/mediachain/aleph/issues/comments{/number}","contents_url":"https://api.github.com/repos/mediachain/aleph/contents/{+path}","compare_url":"https://api.github.com/repos/mediachain/aleph/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mediachain/aleph/merges","archive_url":"https://api.github.com/repos/mediachain/aleph/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mediachain/aleph/downloads","issues_url":"https://api.github.com/repos/mediachain/aleph/issues{/number}","pulls_url":"https://api.github.com/repos/mediachain/aleph/pulls{/number}","milestones_url":"https://api.github.com/repos/mediachain/aleph/milestones{/number}","notifications_url":"https://api.github.com/repos/mediachain/aleph/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mediachain/aleph/labels{/name}","releases_url":"https://api.github.com/repos/mediachain/aleph/releases{/id}","deployments_url":"https://api.github.com/repos/mediachain/aleph/deployments","created_at":"2016-08-30T21:01:45Z","updated_at":"2016-12-03T06:18:07Z","pushed_at":"2016-12-09T16:23:46Z","git_url":"git://github.com/mediachain/aleph.git","ssh_url":"git@github.com:mediachain/aleph.git","clone_url":"https://github.com/mediachain/aleph.git","svn_url":"https://github.com/mediachain/aleph","homepage":"","size":579,"stargazers_count":11,"watchers_count":11,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":19,"forks":3,"open_issues":19,"watchers":11,"default_branch":"master"}},"base":{"label":"mediachain:master","ref":"master","sha":"12328f67b0a53e8d0b6caa8999b432042cdd469f","user":{"login":"mediachain","id":16711838,"avatar_url":"https://avatars.githubusercontent.com/u/16711838?v=3","gravatar_id":"","url":"https://api.github.com/users/mediachain","html_url":"https://github.com/mediachain","followers_url":"https://api.github.com/users/mediachain/followers","following_url":"https://api.github.com/users/mediachain/following{/other_user}","gists_url":"https://api.github.com/users/mediachain/gists{/gist_id}","starred_url":"https://api.github.com/users/mediachain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mediachain/subscriptions","organizations_url":"https://api.github.com/users/mediachain/orgs","repos_url":"https://api.github.com/users/mediachain/repos","events_url":"https://api.github.com/users/mediachain/events{/privacy}","received_events_url":"https://api.github.com/users/mediachain/received_events","type":"Organization","site_admin":false},"repo":{"id":66977529,"name":"aleph","full_name":"mediachain/aleph","owner":{"login":"mediachain","id":16711838,"avatar_url":"https://avatars.githubusercontent.com/u/16711838?v=3","gravatar_id":"","url":"https://api.github.com/users/mediachain","html_url":"https://github.com/mediachain","followers_url":"https://api.github.com/users/mediachain/followers","following_url":"https://api.github.com/users/mediachain/following{/other_user}","gists_url":"https://api.github.com/users/mediachain/gists{/gist_id}","starred_url":"https://api.github.com/users/mediachain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mediachain/subscriptions","organizations_url":"https://api.github.com/users/mediachain/orgs","repos_url":"https://api.github.com/users/mediachain/repos","events_url":"https://api.github.com/users/mediachain/events{/privacy}","received_events_url":"https://api.github.com/users/mediachain/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mediachain/aleph","description":"א: The mediachain universe manipulation engine","fork":false,"url":"https://api.github.com/repos/mediachain/aleph","forks_url":"https://api.github.com/repos/mediachain/aleph/forks","keys_url":"https://api.github.com/repos/mediachain/aleph/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mediachain/aleph/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mediachain/aleph/teams","hooks_url":"https://api.github.com/repos/mediachain/aleph/hooks","issue_events_url":"https://api.github.com/repos/mediachain/aleph/issues/events{/number}","events_url":"https://api.github.com/repos/mediachain/aleph/events","assignees_url":"https://api.github.com/repos/mediachain/aleph/assignees{/user}","branches_url":"https://api.github.com/repos/mediachain/aleph/branches{/branch}","tags_url":"https://api.github.com/repos/mediachain/aleph/tags","blobs_url":"https://api.github.com/repos/mediachain/aleph/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mediachain/aleph/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mediachain/aleph/git/refs{/sha}","trees_url":"https://api.github.com/repos/mediachain/aleph/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mediachain/aleph/statuses/{sha}","languages_url":"https://api.github.com/repos/mediachain/aleph/languages","stargazers_url":"https://api.github.com/repos/mediachain/aleph/stargazers","contributors_url":"https://api.github.com/repos/mediachain/aleph/contributors","subscribers_url":"https://api.github.com/repos/mediachain/aleph/subscribers","subscription_url":"https://api.github.com/repos/mediachain/aleph/subscription","commits_url":"https://api.github.com/repos/mediachain/aleph/commits{/sha}","git_commits_url":"https://api.github.com/repos/mediachain/aleph/git/commits{/sha}","comments_url":"https://api.github.com/repos/mediachain/aleph/comments{/number}","issue_comment_url":"https://api.github.com/repos/mediachain/aleph/issues/comments{/number}","contents_url":"https://api.github.com/repos/mediachain/aleph/contents/{+path}","compare_url":"https://api.github.com/repos/mediachain/aleph/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mediachain/aleph/merges","archive_url":"https://api.github.com/repos/mediachain/aleph/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mediachain/aleph/downloads","issues_url":"https://api.github.com/repos/mediachain/aleph/issues{/number}","pulls_url":"https://api.github.com/repos/mediachain/aleph/pulls{/number}","milestones_url":"https://api.github.com/repos/mediachain/aleph/milestones{/number}","notifications_url":"https://api.github.com/repos/mediachain/aleph/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mediachain/aleph/labels{/name}","releases_url":"https://api.github.com/repos/mediachain/aleph/releases{/id}","deployments_url":"https://api.github.com/repos/mediachain/aleph/deployments","created_at":"2016-08-30T21:01:45Z","updated_at":"2016-12-03T06:18:07Z","pushed_at":"2016-12-09T16:23:46Z","git_url":"git://github.com/mediachain/aleph.git","ssh_url":"git@github.com:mediachain/aleph.git","clone_url":"https://github.com/mediachain/aleph.git","svn_url":"https://github.com/mediachain/aleph","homepage":"","size":579,"stargazers_count":11,"watchers_count":11,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":19,"forks":3,"open_issues":19,"watchers":11,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mediachain/aleph/pulls/123"},"html":{"href":"https://github.com/mediachain/aleph/pull/123"},"issue":{"href":"https://api.github.com/repos/mediachain/aleph/issues/123"},"comments":{"href":"https://api.github.com/repos/mediachain/aleph/issues/123/comments"},"review_comments":{"href":"https://api.github.com/repos/mediachain/aleph/pulls/123/comments"},"review_comment":{"href":"https://api.github.com/repos/mediachain/aleph/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mediachain/aleph/pulls/123/commits"},"statuses":{"href":"https://api.github.com/repos/mediachain/aleph/statuses/f3bee483780445e4451d9df6d1c87a6799981fd9"}}}}
{"actor":{"display_login":"vyzo"}}