{"action":"created","comment":{"url":"https://api.github.com/repos/drn/jira-cli/pulls/comments/49895931","id":49895931,"diff_hunk":"@@ -21,18 +43,91 @@ def comments(ticket=Jira::Core.ticket)\n         if comments.count > 0\n           comments.each do |comment|\n             author = comment['author']['displayName']\n-            time = Time.parse(comment['created'])\n+            time = Time.parse(comment['updated'])\n             body = comment['body']\n \n-            puts \"#{Jira::Format.user(author)} @ \"\\\n+            printf \"[%2d]\", comments.index(comment)\n+            puts \"  #{Jira::Format.user(author)} @ \"\\\n                  \"#{Jira::Format.time(time)}:\\n\"\\\n                  \"#{Jira::Format.comment(body)}\"\n           end\n         else\n-          puts \"There are no comments on issue #{ticket}.\"\n+          puts \"There are no comments on ticket #{ticket}.\"\n+        end\n+      end\n+    end\n+\n+    desc \"commentu\", \"Update a comment to the input ticket\"\n+    def commentu(ticket=Jira::Core.ticket)\n+      if self.io.agree(\"List comments for ticket #{ticket}\")\n+        comments(ticket)\n+      end\n+      idx = self.get_comment_idx(\"update\")\n+      if idx < 0\n+        puts \"No comment updated.\"\n+        return\n+      end\n+      comment = self.get_comment_body(ticket)\n+      if comment.empty?\n+        puts \"No comment updated.\"\n+        return\n+      end\n+      self.api.get(\"issue/#{ticket}\") do |json|\n+        comments = json['fields']['comment']['comments']\n+        if idx < comments.count\n+          id = comments[idx]['id']\n+          self.api.put(\"issue/#{ticket}/comment/#{id}\", { body: comment }) do |json|\n+            puts \"Successfully updated your comment.\"\n+            return\n+          end\n         end\n       end\n+      puts \"No comment updated.\"\n     end\n \n+    protected\n+\n+      #\n+      # Prompts the user for a comment body, strips it, then\n+      # returns a substituted version of it\n+      #\n+      # @return comment [String] asked comment body\n+      #\n+      def get_comment_body(ticket)\n+        comment = self.io.ask(\"Leave a comment for ticket #{ticket}\").strip\n+        if !comment.empty?\n+          temp = comment.gsub(/\\@[a-zA-Z]+/,'[~\\0]')\n+          if temp.nil?\n+            temp = comment\n+          end\n+          temp = temp.gsub('[~@','[~')\n+          if !temp.nil?\n+            comment = temp\n+          end\n+        end\n+        comment\n+      end\n+\n+      #\n+      # Prompts the user for a comment index, then returns the\n+      # comment index; failure is < 0\n+      #\n+      # @param description [String] describes the user prompt\n+      #\n+      # @return idx [Integer] asked comment index\n+      #\n+      def get_comment_idx(description = \"\")\n+        idx = self.io.ask(\"Index for comment to #{description}\").strip","path":"lib/jira/commands/comment.rb","position":124,"original_position":124,"commit_id":"919601e81c38017f77a3e135c9bab0325a1ebd47","original_commit_id":"919601e81c38017f77a3e135c9bab0325a1ebd47","user":{"login":"SDarayan","id":6225529,"avatar_url":"https://avatars.githubusercontent.com/u/6225529?v=3","gravatar_id":"","url":"https://api.github.com/users/SDarayan","html_url":"https://github.com/SDarayan","followers_url":"https://api.github.com/users/SDarayan/followers","following_url":"https://api.github.com/users/SDarayan/following{/other_user}","gists_url":"https://api.github.com/users/SDarayan/gists{/gist_id}","starred_url":"https://api.github.com/users/SDarayan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SDarayan/subscriptions","organizations_url":"https://api.github.com/users/SDarayan/orgs","repos_url":"https://api.github.com/users/SDarayan/repos","events_url":"https://api.github.com/users/SDarayan/events{/privacy}","received_events_url":"https://api.github.com/users/SDarayan/received_events","type":"User","site_admin":false},"body":"I will create a method in mixins.rb and refer to it in log.rb and comment.rb.","created_at":"2016-01-15T19:41:09Z","updated_at":"2016-01-15T19:41:09Z","html_url":"https://github.com/drn/jira-cli/pull/7#discussion_r49895931","pull_request_url":"https://api.github.com/repos/drn/jira-cli/pulls/7","_links":{"self":{"href":"https://api.github.com/repos/drn/jira-cli/pulls/comments/49895931"},"html":{"href":"https://github.com/drn/jira-cli/pull/7#discussion_r49895931"},"pull_request":{"href":"https://api.github.com/repos/drn/jira-cli/pulls/7"}}},"pull_request":{"url":"https://api.github.com/repos/drn/jira-cli/pulls/7","id":56115960,"html_url":"https://github.com/drn/jira-cli/pull/7","diff_url":"https://github.com/drn/jira-cli/pull/7.diff","patch_url":"https://github.com/drn/jira-cli/pull/7.patch","issue_url":"https://api.github.com/repos/drn/jira-cli/issues/7","number":7,"state":"open","locked":false,"title":"Upgrade to 0.2.0","user":{"login":"SDarayan","id":6225529,"avatar_url":"https://avatars.githubusercontent.com/u/6225529?v=3","gravatar_id":"","url":"https://api.github.com/users/SDarayan","html_url":"https://github.com/SDarayan","followers_url":"https://api.github.com/users/SDarayan/followers","following_url":"https://api.github.com/users/SDarayan/following{/other_user}","gists_url":"https://api.github.com/users/SDarayan/gists{/gist_id}","starred_url":"https://api.github.com/users/SDarayan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SDarayan/subscriptions","organizations_url":"https://api.github.com/users/SDarayan/orgs","repos_url":"https://api.github.com/users/SDarayan/repos","events_url":"https://api.github.com/users/SDarayan/events{/privacy}","received_events_url":"https://api.github.com/users/SDarayan/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-01-15T00:37:28Z","updated_at":"2016-01-15T19:41:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4b67eb4cdd91d9975ccd6796d5718e2dc9aef811","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/drn/jira-cli/pulls/7/commits","review_comments_url":"https://api.github.com/repos/drn/jira-cli/pulls/7/comments","review_comment_url":"https://api.github.com/repos/drn/jira-cli/pulls/comments{/number}","comments_url":"https://api.github.com/repos/drn/jira-cli/issues/7/comments","statuses_url":"https://api.github.com/repos/drn/jira-cli/statuses/919601e81c38017f77a3e135c9bab0325a1ebd47","head":{"label":"SDarayan:master","ref":"master","sha":"919601e81c38017f77a3e135c9bab0325a1ebd47","user":{"login":"SDarayan","id":6225529,"avatar_url":"https://avatars.githubusercontent.com/u/6225529?v=3","gravatar_id":"","url":"https://api.github.com/users/SDarayan","html_url":"https://github.com/SDarayan","followers_url":"https://api.github.com/users/SDarayan/followers","following_url":"https://api.github.com/users/SDarayan/following{/other_user}","gists_url":"https://api.github.com/users/SDarayan/gists{/gist_id}","starred_url":"https://api.github.com/users/SDarayan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SDarayan/subscriptions","organizations_url":"https://api.github.com/users/SDarayan/orgs","repos_url":"https://api.github.com/users/SDarayan/repos","events_url":"https://api.github.com/users/SDarayan/events{/privacy}","received_events_url":"https://api.github.com/users/SDarayan/received_events","type":"User","site_admin":false},"repo":{"id":49306483,"name":"jira-cli","full_name":"SDarayan/jira-cli","owner":{"login":"SDarayan","id":6225529,"avatar_url":"https://avatars.githubusercontent.com/u/6225529?v=3","gravatar_id":"","url":"https://api.github.com/users/SDarayan","html_url":"https://github.com/SDarayan","followers_url":"https://api.github.com/users/SDarayan/followers","following_url":"https://api.github.com/users/SDarayan/following{/other_user}","gists_url":"https://api.github.com/users/SDarayan/gists{/gist_id}","starred_url":"https://api.github.com/users/SDarayan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SDarayan/subscriptions","organizations_url":"https://api.github.com/users/SDarayan/orgs","repos_url":"https://api.github.com/users/SDarayan/repos","events_url":"https://api.github.com/users/SDarayan/events{/privacy}","received_events_url":"https://api.github.com/users/SDarayan/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/SDarayan/jira-cli","description":"Ruby gem CLI tool used to manage JIRA workflows leveraging git","fork":true,"url":"https://api.github.com/repos/SDarayan/jira-cli","forks_url":"https://api.github.com/repos/SDarayan/jira-cli/forks","keys_url":"https://api.github.com/repos/SDarayan/jira-cli/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SDarayan/jira-cli/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SDarayan/jira-cli/teams","hooks_url":"https://api.github.com/repos/SDarayan/jira-cli/hooks","issue_events_url":"https://api.github.com/repos/SDarayan/jira-cli/issues/events{/number}","events_url":"https://api.github.com/repos/SDarayan/jira-cli/events","assignees_url":"https://api.github.com/repos/SDarayan/jira-cli/assignees{/user}","branches_url":"https://api.github.com/repos/SDarayan/jira-cli/branches{/branch}","tags_url":"https://api.github.com/repos/SDarayan/jira-cli/tags","blobs_url":"https://api.github.com/repos/SDarayan/jira-cli/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SDarayan/jira-cli/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SDarayan/jira-cli/git/refs{/sha}","trees_url":"https://api.github.com/repos/SDarayan/jira-cli/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SDarayan/jira-cli/statuses/{sha}","languages_url":"https://api.github.com/repos/SDarayan/jira-cli/languages","stargazers_url":"https://api.github.com/repos/SDarayan/jira-cli/stargazers","contributors_url":"https://api.github.com/repos/SDarayan/jira-cli/contributors","subscribers_url":"https://api.github.com/repos/SDarayan/jira-cli/subscribers","subscription_url":"https://api.github.com/repos/SDarayan/jira-cli/subscription","commits_url":"https://api.github.com/repos/SDarayan/jira-cli/commits{/sha}","git_commits_url":"https://api.github.com/repos/SDarayan/jira-cli/git/commits{/sha}","comments_url":"https://api.github.com/repos/SDarayan/jira-cli/comments{/number}","issue_comment_url":"https://api.github.com/repos/SDarayan/jira-cli/issues/comments{/number}","contents_url":"https://api.github.com/repos/SDarayan/jira-cli/contents/{+path}","compare_url":"https://api.github.com/repos/SDarayan/jira-cli/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SDarayan/jira-cli/merges","archive_url":"https://api.github.com/repos/SDarayan/jira-cli/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SDarayan/jira-cli/downloads","issues_url":"https://api.github.com/repos/SDarayan/jira-cli/issues{/number}","pulls_url":"https://api.github.com/repos/SDarayan/jira-cli/pulls{/number}","milestones_url":"https://api.github.com/repos/SDarayan/jira-cli/milestones{/number}","notifications_url":"https://api.github.com/repos/SDarayan/jira-cli/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SDarayan/jira-cli/labels{/name}","releases_url":"https://api.github.com/repos/SDarayan/jira-cli/releases{/id}","created_at":"2016-01-09T01:51:26Z","updated_at":"2016-01-11T21:13:25Z","pushed_at":"2016-01-15T08:30:44Z","git_url":"git://github.com/SDarayan/jira-cli.git","ssh_url":"git@github.com:SDarayan/jira-cli.git","clone_url":"https://github.com/SDarayan/jira-cli.git","svn_url":"https://github.com/SDarayan/jira-cli","homepage":null,"size":94,"stargazers_count":0,"watchers_count":0,"language":"Ruby","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":0,"default_branch":"master"}},"base":{"label":"drn:master","ref":"master","sha":"f3f4da9a26224de1e432fa85ca0bd8018a791327","user":{"login":"drn","id":885841,"avatar_url":"https://avatars.githubusercontent.com/u/885841?v=3","gravatar_id":"","url":"https://api.github.com/users/drn","html_url":"https://github.com/drn","followers_url":"https://api.github.com/users/drn/followers","following_url":"https://api.github.com/users/drn/following{/other_user}","gists_url":"https://api.github.com/users/drn/gists{/gist_id}","starred_url":"https://api.github.com/users/drn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drn/subscriptions","organizations_url":"https://api.github.com/users/drn/orgs","repos_url":"https://api.github.com/users/drn/repos","events_url":"https://api.github.com/users/drn/events{/privacy}","received_events_url":"https://api.github.com/users/drn/received_events","type":"User","site_admin":false},"repo":{"id":14122587,"name":"jira-cli","full_name":"drn/jira-cli","owner":{"login":"drn","id":885841,"avatar_url":"https://avatars.githubusercontent.com/u/885841?v=3","gravatar_id":"","url":"https://api.github.com/users/drn","html_url":"https://github.com/drn","followers_url":"https://api.github.com/users/drn/followers","following_url":"https://api.github.com/users/drn/following{/other_user}","gists_url":"https://api.github.com/users/drn/gists{/gist_id}","starred_url":"https://api.github.com/users/drn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drn/subscriptions","organizations_url":"https://api.github.com/users/drn/orgs","repos_url":"https://api.github.com/users/drn/repos","events_url":"https://api.github.com/users/drn/events{/privacy}","received_events_url":"https://api.github.com/users/drn/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/drn/jira-cli","description":"Ruby gem CLI tool used to manage JIRA workflows leveraging git","fork":false,"url":"https://api.github.com/repos/drn/jira-cli","forks_url":"https://api.github.com/repos/drn/jira-cli/forks","keys_url":"https://api.github.com/repos/drn/jira-cli/keys{/key_id}","collaborators_url":"https://api.github.com/repos/drn/jira-cli/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/drn/jira-cli/teams","hooks_url":"https://api.github.com/repos/drn/jira-cli/hooks","issue_events_url":"https://api.github.com/repos/drn/jira-cli/issues/events{/number}","events_url":"https://api.github.com/repos/drn/jira-cli/events","assignees_url":"https://api.github.com/repos/drn/jira-cli/assignees{/user}","branches_url":"https://api.github.com/repos/drn/jira-cli/branches{/branch}","tags_url":"https://api.github.com/repos/drn/jira-cli/tags","blobs_url":"https://api.github.com/repos/drn/jira-cli/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/drn/jira-cli/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/drn/jira-cli/git/refs{/sha}","trees_url":"https://api.github.com/repos/drn/jira-cli/git/trees{/sha}","statuses_url":"https://api.github.com/repos/drn/jira-cli/statuses/{sha}","languages_url":"https://api.github.com/repos/drn/jira-cli/languages","stargazers_url":"https://api.github.com/repos/drn/jira-cli/stargazers","contributors_url":"https://api.github.com/repos/drn/jira-cli/contributors","subscribers_url":"https://api.github.com/repos/drn/jira-cli/subscribers","subscription_url":"https://api.github.com/repos/drn/jira-cli/subscription","commits_url":"https://api.github.com/repos/drn/jira-cli/commits{/sha}","git_commits_url":"https://api.github.com/repos/drn/jira-cli/git/commits{/sha}","comments_url":"https://api.github.com/repos/drn/jira-cli/comments{/number}","issue_comment_url":"https://api.github.com/repos/drn/jira-cli/issues/comments{/number}","contents_url":"https://api.github.com/repos/drn/jira-cli/contents/{+path}","compare_url":"https://api.github.com/repos/drn/jira-cli/compare/{base}...{head}","merges_url":"https://api.github.com/repos/drn/jira-cli/merges","archive_url":"https://api.github.com/repos/drn/jira-cli/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/drn/jira-cli/downloads","issues_url":"https://api.github.com/repos/drn/jira-cli/issues{/number}","pulls_url":"https://api.github.com/repos/drn/jira-cli/pulls{/number}","milestones_url":"https://api.github.com/repos/drn/jira-cli/milestones{/number}","notifications_url":"https://api.github.com/repos/drn/jira-cli/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/drn/jira-cli/labels{/name}","releases_url":"https://api.github.com/repos/drn/jira-cli/releases{/id}","created_at":"2013-11-04T20:26:35Z","updated_at":"2015-11-05T10:47:08Z","pushed_at":"2016-01-15T08:30:44Z","git_url":"git://github.com/drn/jira-cli.git","ssh_url":"git@github.com:drn/jira-cli.git","clone_url":"https://github.com/drn/jira-cli.git","svn_url":"https://github.com/drn/jira-cli","homepage":null,"size":581,"stargazers_count":9,"watchers_count":9,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":1,"forks":7,"open_issues":1,"watchers":9,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/drn/jira-cli/pulls/7"},"html":{"href":"https://github.com/drn/jira-cli/pull/7"},"issue":{"href":"https://api.github.com/repos/drn/jira-cli/issues/7"},"comments":{"href":"https://api.github.com/repos/drn/jira-cli/issues/7/comments"},"review_comments":{"href":"https://api.github.com/repos/drn/jira-cli/pulls/7/comments"},"review_comment":{"href":"https://api.github.com/repos/drn/jira-cli/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/drn/jira-cli/pulls/7/commits"},"statuses":{"href":"https://api.github.com/repos/drn/jira-cli/statuses/919601e81c38017f77a3e135c9bab0325a1ebd47"}}}}