{"action":"created","comment":{"url":"https://api.github.com/repos/asterisk/node-voicemail-admin/pulls/comments/23822858","id":23822858,"diff_hunk":"@@ -0,0 +1,779 @@\n+/**\n+ * Voicemail Administrator application.\n+ *\n+ * @module voicemail-admin\n+ * @copyright 2014, Digium, Inc.\n+ * @license Apache License, Version 2.0\n+ * @author Jonathan R. Rose <jrose@digium.com>\n+ */\n+\n+'use strict';\n+\n+var menu = require('../menu.json');\n+var prompt = require('prompt');\n+\n+var dal;\n+var logger;\n+\n+var sprintf = require('sprintf').sprintf;\n+\n+var commands = createApi();\n+\n+var Q = require('q');\n+\n+prompt.message = '';\n+prompt.delimiter = '';\n+var inputIndicator = {\n+  name: 'command',\n+  message: '=>'.green\n+};\n+\n+var internalCommands = ['exit', 'help'];\n+\n+/**\n+ * Returns a promise that resolves when the requested command is finished\n+ * executing.\n+ *\n+ * @param {object} result - command entered by prompt.get()\n+ */\n+function processOption(result) {\n+  var entryComponents;\n+  var baseCommand;\n+  var chosenCommand = false;\n+  var functionPtr;\n+  var index;\n+\n+  return Q.fcall(function () {\n+    if (!result || !result.command) {\n+      return exit();\n+    }\n+\n+    /* Split the string by spaces, but keep stuff between quotes together */\n+    entryComponents = result.command.match(/(?:[^\\s\"]+|\"[^\"]*\")+/g);\n+\n+    if (!entryComponents) {\n+      return;\n+    }\n+\n+    entryComponents = entryComponents.map(function(component) {\n+      return component.replace(/\"/g, '');\n+    });\n+\n+    /* help is the only single word command -- everything else is two words */\n+    if (entryComponents.length === 1 ||\n+        internalCommands.indexOf(entryComponents[0]) > -1) {\n+      baseCommand = entryComponents[0];\n+    } else {\n+      baseCommand = entryComponents[0] + ' ' + entryComponents[1];\n+    }\n+\n+    chosenCommand = menu.commands[baseCommand];\n+\n+    if (!chosenCommand) {\n+      throw new Error(sprintf('Unknown command \\'%s\\'', result.command));\n+    }\n+\n+    functionPtr = commands[chosenCommand.action];\n+\n+    return functionPtr(chosenCommand, entryComponents);\n+  })\n+  .catch(function (error) {\n+    logger.error('%s', error);\n+  });\n+}\n+\n+var getPrompt = Q.denodeify(prompt.get);\n+\n+/**\n+ * Prints detailed help information for a single command to the terminal\n+ *\n+ * @param {array} entryComponents - all parts of the command as it was entered\n+ */\n+function showHelpCommand(entryComponents) {\n+  var commandName;\n+  var chosenCommand = false;\n+\n+  /* entry components must be array of 2 or greater */\n+  if (entryComponents.length === 2) {\n+    commandName = entryComponents[1];\n+  } else {\n+    commandName = entryComponents[1] + ' ' + entryComponents[2];\n+  }\n+\n+  chosenCommand = menu.commands[commandName];\n+\n+  if (!chosenCommand) {\n+    throw new Error('Command: \\'%s\\' does not exist.');\n+  }\n+\n+  logger.info('Usage: ' + chosenCommand.usage.green);\n+  logger.info(chosenCommand.description);\n+\n+  chosenCommand.details.forEach(function (detail) {\n+    logger.info(detail);\n+  });\n+}\n+\n+/**\n+ * Removes keys from an associative array that are either functions or objects\n+ *\n+ * @param {object} associativeArray - associative array to cull junk from\n+ */\n+function removeUgly(associativeArray) {","path":"lib/voicemail-admin.js","position":122,"original_position":122,"commit_id":"98f9945e48f1f62c004e1d155de142e213acd4e8","original_commit_id":"98f9945e48f1f62c004e1d155de142e213acd4e8","user":{"login":"samuelg","id":21962,"avatar_url":"https://avatars.githubusercontent.com/u/21962?v=3","gravatar_id":"","url":"https://api.github.com/users/samuelg","html_url":"https://github.com/samuelg","followers_url":"https://api.github.com/users/samuelg/followers","following_url":"https://api.github.com/users/samuelg/following{/other_user}","gists_url":"https://api.github.com/users/samuelg/gists{/gist_id}","starred_url":"https://api.github.com/users/samuelg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samuelg/subscriptions","organizations_url":"https://api.github.com/users/samuelg/orgs","repos_url":"https://api.github.com/users/samuelg/repos","events_url":"https://api.github.com/users/samuelg/events{/privacy}","received_events_url":"https://api.github.com/users/samuelg/received_events","type":"User","site_admin":false},"body":"May want to rename this method. It's not very descriptive.","created_at":"2015-01-30T03:53:50Z","updated_at":"2015-01-30T03:53:50Z","html_url":"https://github.com/asterisk/node-voicemail-admin/pull/2#discussion_r23822858","pull_request_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/asterisk/node-voicemail-admin/pulls/comments/23822858"},"html":{"href":"https://github.com/asterisk/node-voicemail-admin/pull/2#discussion_r23822858"},"pull_request":{"href":"https://api.github.com/repos/asterisk/node-voicemail-admin/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/asterisk/node-voicemail-admin/pulls/2","id":27541131,"html_url":"https://github.com/asterisk/node-voicemail-admin/pull/2","diff_url":"https://github.com/asterisk/node-voicemail-admin/pull/2.diff","patch_url":"https://github.com/asterisk/node-voicemail-admin/pull/2.patch","issue_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/issues/2","number":2,"state":"open","locked":false,"title":"Everything from Before Plus Tests","user":{"login":"jrrose","id":768742,"avatar_url":"https://avatars.githubusercontent.com/u/768742?v=3","gravatar_id":"","url":"https://api.github.com/users/jrrose","html_url":"https://github.com/jrrose","followers_url":"https://api.github.com/users/jrrose/followers","following_url":"https://api.github.com/users/jrrose/following{/other_user}","gists_url":"https://api.github.com/users/jrrose/gists{/gist_id}","starred_url":"https://api.github.com/users/jrrose/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jrrose/subscriptions","organizations_url":"https://api.github.com/users/jrrose/orgs","repos_url":"https://api.github.com/users/jrrose/repos","events_url":"https://api.github.com/users/jrrose/events{/privacy}","received_events_url":"https://api.github.com/users/jrrose/received_events","type":"User","site_admin":false},"body":"Because I suck at git, I closed the previous pull request and created a new one.","created_at":"2015-01-16T22:20:12Z","updated_at":"2015-01-30T03:53:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"51a9ef55713f127eb143ac720e851873fd177441","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/pulls/2/commits","review_comments_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/pulls/2/comments","review_comment_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/pulls/comments/{number}","comments_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/issues/2/comments","statuses_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/statuses/98f9945e48f1f62c004e1d155de142e213acd4e8","head":{"label":"asterisk:create_tests","ref":"create_tests","sha":"98f9945e48f1f62c004e1d155de142e213acd4e8","user":{"login":"asterisk","id":2914369,"avatar_url":"https://avatars.githubusercontent.com/u/2914369?v=3","gravatar_id":"","url":"https://api.github.com/users/asterisk","html_url":"https://github.com/asterisk","followers_url":"https://api.github.com/users/asterisk/followers","following_url":"https://api.github.com/users/asterisk/following{/other_user}","gists_url":"https://api.github.com/users/asterisk/gists{/gist_id}","starred_url":"https://api.github.com/users/asterisk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asterisk/subscriptions","organizations_url":"https://api.github.com/users/asterisk/orgs","repos_url":"https://api.github.com/users/asterisk/repos","events_url":"https://api.github.com/users/asterisk/events{/privacy}","received_events_url":"https://api.github.com/users/asterisk/received_events","type":"Organization","site_admin":false},"repo":{"id":27508650,"name":"node-voicemail-admin","full_name":"asterisk/node-voicemail-admin","owner":{"login":"asterisk","id":2914369,"avatar_url":"https://avatars.githubusercontent.com/u/2914369?v=3","gravatar_id":"","url":"https://api.github.com/users/asterisk","html_url":"https://github.com/asterisk","followers_url":"https://api.github.com/users/asterisk/followers","following_url":"https://api.github.com/users/asterisk/following{/other_user}","gists_url":"https://api.github.com/users/asterisk/gists{/gist_id}","starred_url":"https://api.github.com/users/asterisk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asterisk/subscriptions","organizations_url":"https://api.github.com/users/asterisk/orgs","repos_url":"https://api.github.com/users/asterisk/repos","events_url":"https://api.github.com/users/asterisk/events{/privacy}","received_events_url":"https://api.github.com/users/asterisk/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/asterisk/node-voicemail-admin","description":"A command line administration tool for managing mailboxes in node-voicemail","fork":false,"url":"https://api.github.com/repos/asterisk/node-voicemail-admin","forks_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/forks","keys_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/teams","hooks_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/hooks","issue_events_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/issues/events{/number}","events_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/events","assignees_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/assignees{/user}","branches_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/branches{/branch}","tags_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/tags","blobs_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/git/refs{/sha}","trees_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/statuses/{sha}","languages_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/languages","stargazers_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/stargazers","contributors_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/contributors","subscribers_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/subscribers","subscription_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/subscription","commits_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/commits{/sha}","git_commits_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/git/commits{/sha}","comments_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/comments{/number}","issue_comment_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/issues/comments/{number}","contents_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/contents/{+path}","compare_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/merges","archive_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/downloads","issues_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/issues{/number}","pulls_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/pulls{/number}","milestones_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/milestones{/number}","notifications_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/labels{/name}","releases_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/releases{/id}","created_at":"2014-12-03T21:31:26Z","updated_at":"2015-01-16T22:55:20Z","pushed_at":"2015-01-23T20:10:22Z","git_url":"git://github.com/asterisk/node-voicemail-admin.git","ssh_url":"git@github.com:asterisk/node-voicemail-admin.git","clone_url":"https://github.com/asterisk/node-voicemail-admin.git","svn_url":"https://github.com/asterisk/node-voicemail-admin","homepage":null,"size":256,"stargazers_count":1,"watchers_count":1,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":1,"default_branch":"master"}},"base":{"label":"asterisk:master","ref":"master","sha":"5ddcd2ff01d4d3269efb8d23492bc3c9a49fb255","user":{"login":"asterisk","id":2914369,"avatar_url":"https://avatars.githubusercontent.com/u/2914369?v=3","gravatar_id":"","url":"https://api.github.com/users/asterisk","html_url":"https://github.com/asterisk","followers_url":"https://api.github.com/users/asterisk/followers","following_url":"https://api.github.com/users/asterisk/following{/other_user}","gists_url":"https://api.github.com/users/asterisk/gists{/gist_id}","starred_url":"https://api.github.com/users/asterisk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asterisk/subscriptions","organizations_url":"https://api.github.com/users/asterisk/orgs","repos_url":"https://api.github.com/users/asterisk/repos","events_url":"https://api.github.com/users/asterisk/events{/privacy}","received_events_url":"https://api.github.com/users/asterisk/received_events","type":"Organization","site_admin":false},"repo":{"id":27508650,"name":"node-voicemail-admin","full_name":"asterisk/node-voicemail-admin","owner":{"login":"asterisk","id":2914369,"avatar_url":"https://avatars.githubusercontent.com/u/2914369?v=3","gravatar_id":"","url":"https://api.github.com/users/asterisk","html_url":"https://github.com/asterisk","followers_url":"https://api.github.com/users/asterisk/followers","following_url":"https://api.github.com/users/asterisk/following{/other_user}","gists_url":"https://api.github.com/users/asterisk/gists{/gist_id}","starred_url":"https://api.github.com/users/asterisk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asterisk/subscriptions","organizations_url":"https://api.github.com/users/asterisk/orgs","repos_url":"https://api.github.com/users/asterisk/repos","events_url":"https://api.github.com/users/asterisk/events{/privacy}","received_events_url":"https://api.github.com/users/asterisk/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/asterisk/node-voicemail-admin","description":"A command line administration tool for managing mailboxes in node-voicemail","fork":false,"url":"https://api.github.com/repos/asterisk/node-voicemail-admin","forks_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/forks","keys_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/teams","hooks_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/hooks","issue_events_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/issues/events{/number}","events_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/events","assignees_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/assignees{/user}","branches_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/branches{/branch}","tags_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/tags","blobs_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/git/refs{/sha}","trees_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/statuses/{sha}","languages_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/languages","stargazers_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/stargazers","contributors_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/contributors","subscribers_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/subscribers","subscription_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/subscription","commits_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/commits{/sha}","git_commits_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/git/commits{/sha}","comments_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/comments{/number}","issue_comment_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/issues/comments/{number}","contents_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/contents/{+path}","compare_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/merges","archive_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/downloads","issues_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/issues{/number}","pulls_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/pulls{/number}","milestones_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/milestones{/number}","notifications_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/labels{/name}","releases_url":"https://api.github.com/repos/asterisk/node-voicemail-admin/releases{/id}","created_at":"2014-12-03T21:31:26Z","updated_at":"2015-01-16T22:55:20Z","pushed_at":"2015-01-23T20:10:22Z","git_url":"git://github.com/asterisk/node-voicemail-admin.git","ssh_url":"git@github.com:asterisk/node-voicemail-admin.git","clone_url":"https://github.com/asterisk/node-voicemail-admin.git","svn_url":"https://github.com/asterisk/node-voicemail-admin","homepage":null,"size":256,"stargazers_count":1,"watchers_count":1,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/asterisk/node-voicemail-admin/pulls/2"},"html":{"href":"https://github.com/asterisk/node-voicemail-admin/pull/2"},"issue":{"href":"https://api.github.com/repos/asterisk/node-voicemail-admin/issues/2"},"comments":{"href":"https://api.github.com/repos/asterisk/node-voicemail-admin/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/asterisk/node-voicemail-admin/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/asterisk/node-voicemail-admin/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/asterisk/node-voicemail-admin/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/asterisk/node-voicemail-admin/statuses/98f9945e48f1f62c004e1d155de142e213acd4e8"}}}}