{"action":"created","comment":{"url":"https://api.github.com/repos/crowbar/crowbar-client/pulls/comments/42764754","id":42764754,"diff_hunk":"@@ -101,33 +104,114 @@ module Proposal\n             parent.desc \"Create a proposal for specific barclamp\"\n             parent.arg :barclamp\n             parent.arg :proposal\n-            parent.command :create do |c|\n+            parent.command \"create\" do |c|\n+              c.desc \"Proposal data in json format\"\n+              c.flag [:data], type: String, default_value: nil\n+\n+              c.desc \"Proposal data as a json file\"\n+              c.flag [:file], type: String, default_value: nil\n+\n               c.action do |global, opts, args|\n                 barclamp = args.shift\n                 proposal = args.shift\n                 helper.validate_availability_of! barclamp\n \n-                fail \"Not implemented yet! (#{barclamp}, #{proposal})\"\n+                # TODO(should): Preload the template from API\n+\n+                content = case\n+                when opts[:data]\n+                  begin\n+                    JSON.load opts[:data]\n+                  rescue\n+                    exit_now! \"Invalid json data\"\n+                  end\n+                when opts[:file]\n+                  begin\n+                    JSON.load opts[:file]\n+                  rescue\n+                    exit_now! \"Invalid json file\"\n+                  end\n+                else\n+                  begin\n+                    editor = Util::Editor.new content: {}\n+                    editor.edit!\n+\n+                    editor.result\n+                  rescue EditorAbortError => e\n+                    exit_now! e.message\n+                  rescue EditorStartupError => e\n+                    exit_now! e.message\n+                  rescue InvalidJsonError => e\n+                    exit_now! e.message\n+                  rescue\n+                    exit_now! \"Editing content failed\"\n+                  end\n+                end\n+\n+                raise content.inspect\n+\n               end\n             end\n \n             parent.desc \"Edit a proposal for specific barclamp\"\n             parent.arg :barclamp\n             parent.arg :proposal\n-            parent.command :edit do |c|\n+            parent.command \"edit\" do |c|\n+              c.desc \"Proposal data in json format\"\n+              c.flag [:data], type: String, default_value: nil\n+\n+              c.desc \"Proposal data as a json file\"\n+              c.flag [:file], type: String, default_value: nil\n+\n               c.action do |global, opts, args|\n                 barclamp = args.shift\n                 proposal = args.shift\n                 helper.validate_availability_of! barclamp\n \n-                fail \"Not implemented yet! (#{barclamp}, #{proposal})\"\n+                original = Request.instance.proposal_show(\n+                  barclamp,\n+                  proposal\n+                ).parsed_response\n+\n+                content = case\n+                when opts[:data]","path":"lib/crowbar/client/command/proposal.rb","position":196,"original_position":196,"commit_id":"ba1793630d0060adebb1f589c4c98330101563cc","original_commit_id":"ba1793630d0060adebb1f589c4c98330101563cc","user":{"login":"houndci","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci","html_url":"https://github.com/houndci","followers_url":"https://api.github.com/users/houndci/followers","following_url":"https://api.github.com/users/houndci/following{/other_user}","gists_url":"https://api.github.com/users/houndci/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci/subscriptions","organizations_url":"https://api.github.com/users/houndci/orgs","repos_url":"https://api.github.com/users/houndci/repos","events_url":"https://api.github.com/users/houndci/events{/privacy}","received_events_url":"https://api.github.com/users/houndci/received_events","type":"User","site_admin":false},"body":"Style/CaseIndentation: Indent `when` as deep as `case`. (https://github.com/bbatsov/ruby-style-guide#indent-when-to-case)","created_at":"2015-10-22T15:39:22Z","updated_at":"2015-10-22T15:39:22Z","html_url":"https://github.com/crowbar/crowbar-client/pull/12#discussion_r42764754","pull_request_url":"https://api.github.com/repos/crowbar/crowbar-client/pulls/12","_links":{"self":{"href":"https://api.github.com/repos/crowbar/crowbar-client/pulls/comments/42764754"},"html":{"href":"https://github.com/crowbar/crowbar-client/pull/12#discussion_r42764754"},"pull_request":{"href":"https://api.github.com/repos/crowbar/crowbar-client/pulls/12"}}},"pull_request":{"url":"https://api.github.com/repos/crowbar/crowbar-client/pulls/12","id":48474111,"html_url":"https://github.com/crowbar/crowbar-client/pull/12","diff_url":"https://github.com/crowbar/crowbar-client/pull/12.diff","patch_url":"https://github.com/crowbar/crowbar-client/pull/12.patch","issue_url":"https://api.github.com/repos/crowbar/crowbar-client/issues/12","number":12,"state":"open","locked":false,"title":"[WIP] Implemented all required proposal subcommands","user":{"login":"tboerger","id":156964,"avatar_url":"https://avatars.githubusercontent.com/u/156964?v=3","gravatar_id":"","url":"https://api.github.com/users/tboerger","html_url":"https://github.com/tboerger","followers_url":"https://api.github.com/users/tboerger/followers","following_url":"https://api.github.com/users/tboerger/following{/other_user}","gists_url":"https://api.github.com/users/tboerger/gists{/gist_id}","starred_url":"https://api.github.com/users/tboerger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tboerger/subscriptions","organizations_url":"https://api.github.com/users/tboerger/orgs","repos_url":"https://api.github.com/users/tboerger/repos","events_url":"https://api.github.com/users/tboerger/events{/privacy}","received_events_url":"https://api.github.com/users/tboerger/received_events","type":"User","site_admin":false},"body":"The code is currently not DRY and I have not integrated tests yet. Hopefully we can take some time afterwards to reduce the duplication and to make it really rocksolid with tests.","created_at":"2015-10-22T15:39:09Z","updated_at":"2015-10-22T15:39:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/crowbar/crowbar-client/pulls/12/commits","review_comments_url":"https://api.github.com/repos/crowbar/crowbar-client/pulls/12/comments","review_comment_url":"https://api.github.com/repos/crowbar/crowbar-client/pulls/comments{/number}","comments_url":"https://api.github.com/repos/crowbar/crowbar-client/issues/12/comments","statuses_url":"https://api.github.com/repos/crowbar/crowbar-client/statuses/ba1793630d0060adebb1f589c4c98330101563cc","head":{"label":"tboerger:feature/proposal","ref":"feature/proposal","sha":"ba1793630d0060adebb1f589c4c98330101563cc","user":{"login":"tboerger","id":156964,"avatar_url":"https://avatars.githubusercontent.com/u/156964?v=3","gravatar_id":"","url":"https://api.github.com/users/tboerger","html_url":"https://github.com/tboerger","followers_url":"https://api.github.com/users/tboerger/followers","following_url":"https://api.github.com/users/tboerger/following{/other_user}","gists_url":"https://api.github.com/users/tboerger/gists{/gist_id}","starred_url":"https://api.github.com/users/tboerger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tboerger/subscriptions","organizations_url":"https://api.github.com/users/tboerger/orgs","repos_url":"https://api.github.com/users/tboerger/repos","events_url":"https://api.github.com/users/tboerger/events{/privacy}","received_events_url":"https://api.github.com/users/tboerger/received_events","type":"User","site_admin":false},"repo":{"id":44047963,"name":"crowbar-client","full_name":"tboerger/crowbar-client","owner":{"login":"tboerger","id":156964,"avatar_url":"https://avatars.githubusercontent.com/u/156964?v=3","gravatar_id":"","url":"https://api.github.com/users/tboerger","html_url":"https://github.com/tboerger","followers_url":"https://api.github.com/users/tboerger/followers","following_url":"https://api.github.com/users/tboerger/following{/other_user}","gists_url":"https://api.github.com/users/tboerger/gists{/gist_id}","starred_url":"https://api.github.com/users/tboerger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tboerger/subscriptions","organizations_url":"https://api.github.com/users/tboerger/orgs","repos_url":"https://api.github.com/users/tboerger/repos","events_url":"https://api.github.com/users/tboerger/events{/privacy}","received_events_url":"https://api.github.com/users/tboerger/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tboerger/crowbar-client","description":"Command line client for Crowbar","fork":true,"url":"https://api.github.com/repos/tboerger/crowbar-client","forks_url":"https://api.github.com/repos/tboerger/crowbar-client/forks","keys_url":"https://api.github.com/repos/tboerger/crowbar-client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tboerger/crowbar-client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tboerger/crowbar-client/teams","hooks_url":"https://api.github.com/repos/tboerger/crowbar-client/hooks","issue_events_url":"https://api.github.com/repos/tboerger/crowbar-client/issues/events{/number}","events_url":"https://api.github.com/repos/tboerger/crowbar-client/events","assignees_url":"https://api.github.com/repos/tboerger/crowbar-client/assignees{/user}","branches_url":"https://api.github.com/repos/tboerger/crowbar-client/branches{/branch}","tags_url":"https://api.github.com/repos/tboerger/crowbar-client/tags","blobs_url":"https://api.github.com/repos/tboerger/crowbar-client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tboerger/crowbar-client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tboerger/crowbar-client/git/refs{/sha}","trees_url":"https://api.github.com/repos/tboerger/crowbar-client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tboerger/crowbar-client/statuses/{sha}","languages_url":"https://api.github.com/repos/tboerger/crowbar-client/languages","stargazers_url":"https://api.github.com/repos/tboerger/crowbar-client/stargazers","contributors_url":"https://api.github.com/repos/tboerger/crowbar-client/contributors","subscribers_url":"https://api.github.com/repos/tboerger/crowbar-client/subscribers","subscription_url":"https://api.github.com/repos/tboerger/crowbar-client/subscription","commits_url":"https://api.github.com/repos/tboerger/crowbar-client/commits{/sha}","git_commits_url":"https://api.github.com/repos/tboerger/crowbar-client/git/commits{/sha}","comments_url":"https://api.github.com/repos/tboerger/crowbar-client/comments{/number}","issue_comment_url":"https://api.github.com/repos/tboerger/crowbar-client/issues/comments{/number}","contents_url":"https://api.github.com/repos/tboerger/crowbar-client/contents/{+path}","compare_url":"https://api.github.com/repos/tboerger/crowbar-client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tboerger/crowbar-client/merges","archive_url":"https://api.github.com/repos/tboerger/crowbar-client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tboerger/crowbar-client/downloads","issues_url":"https://api.github.com/repos/tboerger/crowbar-client/issues{/number}","pulls_url":"https://api.github.com/repos/tboerger/crowbar-client/pulls{/number}","milestones_url":"https://api.github.com/repos/tboerger/crowbar-client/milestones{/number}","notifications_url":"https://api.github.com/repos/tboerger/crowbar-client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tboerger/crowbar-client/labels{/name}","releases_url":"https://api.github.com/repos/tboerger/crowbar-client/releases{/id}","created_at":"2015-10-11T10:31:42Z","updated_at":"2015-10-11T10:31:43Z","pushed_at":"2015-10-22T15:37:43Z","git_url":"git://github.com/tboerger/crowbar-client.git","ssh_url":"git@github.com:tboerger/crowbar-client.git","clone_url":"https://github.com/tboerger/crowbar-client.git","svn_url":"https://github.com/tboerger/crowbar-client","homepage":"","size":118,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"crowbar:master","ref":"master","sha":"ae9d02807e8f0ab8e547b35f7d6567de7de4a486","user":{"login":"crowbar","id":2910205,"avatar_url":"https://avatars.githubusercontent.com/u/2910205?v=3","gravatar_id":"","url":"https://api.github.com/users/crowbar","html_url":"https://github.com/crowbar","followers_url":"https://api.github.com/users/crowbar/followers","following_url":"https://api.github.com/users/crowbar/following{/other_user}","gists_url":"https://api.github.com/users/crowbar/gists{/gist_id}","starred_url":"https://api.github.com/users/crowbar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crowbar/subscriptions","organizations_url":"https://api.github.com/users/crowbar/orgs","repos_url":"https://api.github.com/users/crowbar/repos","events_url":"https://api.github.com/users/crowbar/events{/privacy}","received_events_url":"https://api.github.com/users/crowbar/received_events","type":"Organization","site_admin":false},"repo":{"id":39223531,"name":"crowbar-client","full_name":"crowbar/crowbar-client","owner":{"login":"crowbar","id":2910205,"avatar_url":"https://avatars.githubusercontent.com/u/2910205?v=3","gravatar_id":"","url":"https://api.github.com/users/crowbar","html_url":"https://github.com/crowbar","followers_url":"https://api.github.com/users/crowbar/followers","following_url":"https://api.github.com/users/crowbar/following{/other_user}","gists_url":"https://api.github.com/users/crowbar/gists{/gist_id}","starred_url":"https://api.github.com/users/crowbar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crowbar/subscriptions","organizations_url":"https://api.github.com/users/crowbar/orgs","repos_url":"https://api.github.com/users/crowbar/repos","events_url":"https://api.github.com/users/crowbar/events{/privacy}","received_events_url":"https://api.github.com/users/crowbar/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/crowbar/crowbar-client","description":"Command line client for Crowbar","fork":false,"url":"https://api.github.com/repos/crowbar/crowbar-client","forks_url":"https://api.github.com/repos/crowbar/crowbar-client/forks","keys_url":"https://api.github.com/repos/crowbar/crowbar-client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/crowbar/crowbar-client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/crowbar/crowbar-client/teams","hooks_url":"https://api.github.com/repos/crowbar/crowbar-client/hooks","issue_events_url":"https://api.github.com/repos/crowbar/crowbar-client/issues/events{/number}","events_url":"https://api.github.com/repos/crowbar/crowbar-client/events","assignees_url":"https://api.github.com/repos/crowbar/crowbar-client/assignees{/user}","branches_url":"https://api.github.com/repos/crowbar/crowbar-client/branches{/branch}","tags_url":"https://api.github.com/repos/crowbar/crowbar-client/tags","blobs_url":"https://api.github.com/repos/crowbar/crowbar-client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/crowbar/crowbar-client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/crowbar/crowbar-client/git/refs{/sha}","trees_url":"https://api.github.com/repos/crowbar/crowbar-client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/crowbar/crowbar-client/statuses/{sha}","languages_url":"https://api.github.com/repos/crowbar/crowbar-client/languages","stargazers_url":"https://api.github.com/repos/crowbar/crowbar-client/stargazers","contributors_url":"https://api.github.com/repos/crowbar/crowbar-client/contributors","subscribers_url":"https://api.github.com/repos/crowbar/crowbar-client/subscribers","subscription_url":"https://api.github.com/repos/crowbar/crowbar-client/subscription","commits_url":"https://api.github.com/repos/crowbar/crowbar-client/commits{/sha}","git_commits_url":"https://api.github.com/repos/crowbar/crowbar-client/git/commits{/sha}","comments_url":"https://api.github.com/repos/crowbar/crowbar-client/comments{/number}","issue_comment_url":"https://api.github.com/repos/crowbar/crowbar-client/issues/comments{/number}","contents_url":"https://api.github.com/repos/crowbar/crowbar-client/contents/{+path}","compare_url":"https://api.github.com/repos/crowbar/crowbar-client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/crowbar/crowbar-client/merges","archive_url":"https://api.github.com/repos/crowbar/crowbar-client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/crowbar/crowbar-client/downloads","issues_url":"https://api.github.com/repos/crowbar/crowbar-client/issues{/number}","pulls_url":"https://api.github.com/repos/crowbar/crowbar-client/pulls{/number}","milestones_url":"https://api.github.com/repos/crowbar/crowbar-client/milestones{/number}","notifications_url":"https://api.github.com/repos/crowbar/crowbar-client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/crowbar/crowbar-client/labels{/name}","releases_url":"https://api.github.com/repos/crowbar/crowbar-client/releases{/id}","created_at":"2015-07-16T22:29:43Z","updated_at":"2015-08-20T13:44:23Z","pushed_at":"2015-10-22T15:39:09Z","git_url":"git://github.com/crowbar/crowbar-client.git","ssh_url":"git@github.com:crowbar/crowbar-client.git","clone_url":"https://github.com/crowbar/crowbar-client.git","svn_url":"https://github.com/crowbar/crowbar-client","homepage":"","size":194,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":7,"forks":5,"open_issues":7,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/crowbar/crowbar-client/pulls/12"},"html":{"href":"https://github.com/crowbar/crowbar-client/pull/12"},"issue":{"href":"https://api.github.com/repos/crowbar/crowbar-client/issues/12"},"comments":{"href":"https://api.github.com/repos/crowbar/crowbar-client/issues/12/comments"},"review_comments":{"href":"https://api.github.com/repos/crowbar/crowbar-client/pulls/12/comments"},"review_comment":{"href":"https://api.github.com/repos/crowbar/crowbar-client/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/crowbar/crowbar-client/pulls/12/commits"},"statuses":{"href":"https://api.github.com/repos/crowbar/crowbar-client/statuses/ba1793630d0060adebb1f589c4c98330101563cc"}}}}