{"action":"created","comment":{"url":"https://api.github.com/repos/chef/omnibus-ctl/pulls/comments/37500282","id":37500282,"diff_hunk":"@@ -176,12 +178,28 @@ def add_command_under_category(name, category, description, arity=1, &block)\n       @category_command_map[category] = {} unless @category_command_map.has_key?(category)\n       @category_command_map[category][name] = { :desc => description, :arity => arity }\n       metaclass = class << self; self; end\n-      # Ruby does not like dashes in method names\n       method_name = name.gsub(/-/, \"_\")\n       metaclass.send(:define_method, method_name.to_sym) { |*args| block.call(*args) }\n     end\n \n-    def exit!(error_code)\n+    def exit!(error_code, cmd_name = nil)\n+      # Rather than force every caller of exit! (which is pretty much\n+      # everywhere) to pass in an additional argument, we're going to instead\n+      # take a peak - if we recognize the calling method as a valid command,\n+      # we're process a post-hook for that command. For those that are indirectly calling\n+      # exit! from a common function, they can provide the name.\n+      if cmd_name.nil?\n+        cmd_name = caller[0][/`.*'/][1..-2]","path":"lib/omnibus-ctl.rb","position":55,"original_position":55,"commit_id":"b38ceb6833db291d968781573504e1a6f4a1264f","original_commit_id":"b38ceb6833db291d968781573504e1a6f4a1264f","user":{"login":"stevendanna","id":852371,"avatar_url":"https://avatars.githubusercontent.com/u/852371?v=3","gravatar_id":"","url":"https://api.github.com/users/stevendanna","html_url":"https://github.com/stevendanna","followers_url":"https://api.github.com/users/stevendanna/followers","following_url":"https://api.github.com/users/stevendanna/following{/other_user}","gists_url":"https://api.github.com/users/stevendanna/gists{/gist_id}","starred_url":"https://api.github.com/users/stevendanna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stevendanna/subscriptions","organizations_url":"https://api.github.com/users/stevendanna/orgs","repos_url":"https://api.github.com/users/stevendanna/repos","events_url":"https://api.github.com/users/stevendanna/events{/privacy}","received_events_url":"https://api.github.com/users/stevendanna/received_events","type":"User","site_admin":false},"body":"If you don't find something better, we should comment on how this expression works.","created_at":"2015-08-20T07:03:23Z","updated_at":"2015-08-20T07:03:23Z","html_url":"https://github.com/chef/omnibus-ctl/pull/36#discussion_r37500282","pull_request_url":"https://api.github.com/repos/chef/omnibus-ctl/pulls/36","_links":{"self":{"href":"https://api.github.com/repos/chef/omnibus-ctl/pulls/comments/37500282"},"html":{"href":"https://github.com/chef/omnibus-ctl/pull/36#discussion_r37500282"},"pull_request":{"href":"https://api.github.com/repos/chef/omnibus-ctl/pulls/36"}}},"pull_request":{"url":"https://api.github.com/repos/chef/omnibus-ctl/pulls/36","id":42849691,"html_url":"https://github.com/chef/omnibus-ctl/pull/36","diff_url":"https://github.com/chef/omnibus-ctl/pull/36.diff","patch_url":"https://github.com/chef/omnibus-ctl/pull/36.patch","issue_url":"https://api.github.com/repos/chef/omnibus-ctl/issues/36","number":36,"state":"open","locked":false,"title":"command callback hooks, and make 'cleanse' aware of external services","user":{"login":"marcparadise","id":1130204,"avatar_url":"https://avatars.githubusercontent.com/u/1130204?v=3","gravatar_id":"","url":"https://api.github.com/users/marcparadise","html_url":"https://github.com/marcparadise","followers_url":"https://api.github.com/users/marcparadise/followers","following_url":"https://api.github.com/users/marcparadise/following{/other_user}","gists_url":"https://api.github.com/users/marcparadise/gists{/gist_id}","starred_url":"https://api.github.com/users/marcparadise/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marcparadise/subscriptions","organizations_url":"https://api.github.com/users/marcparadise/orgs","repos_url":"https://api.github.com/users/marcparadise/repos","events_url":"https://api.github.com/users/marcparadise/events{/privacy}","received_events_url":"https://api.github.com/users/marcparadise/received_events","type":"User","site_admin":false},"body":"This PR adds overridable subclass callbacks for execution pre/post command run, allowing subclasses to customize command behaviors.  In particular, this is being used first by chef-server-ctl to \r\n\r\n-  added hooks for command pre/post run.  pre-command hooks can cause a\r\n  command to be aborted by returning false. \r\n- cleanse: new flag --with-external, used by hooks for components that\r\n  may house their data externally and will need to clean then via means other than nuking /var/lib. \r\n- cleanse: output doc format changes and additional words to explain\r\n  the effects of using/not using --with-external\r\n- moved `backup_dir` to instance var. This allows subclasses hooking that command access to the backup location for `cleanse`. \r\n\r\n/cc @chef/lob \r\n\r\nSee also: https://github.com/chef/chef-server/pull/486\r\n","created_at":"2015-08-19T18:47:29Z","updated_at":"2015-08-20T07:03:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4491a47a32da0d909f947c0d42998245dbf88603","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/chef/omnibus-ctl/pulls/36/commits","review_comments_url":"https://api.github.com/repos/chef/omnibus-ctl/pulls/36/comments","review_comment_url":"https://api.github.com/repos/chef/omnibus-ctl/pulls/comments{/number}","comments_url":"https://api.github.com/repos/chef/omnibus-ctl/issues/36/comments","statuses_url":"https://api.github.com/repos/chef/omnibus-ctl/statuses/b38ceb6833db291d968781573504e1a6f4a1264f","head":{"label":"chef:mp/command-callback-hooks","ref":"mp/command-callback-hooks","sha":"b38ceb6833db291d968781573504e1a6f4a1264f","user":{"login":"chef","id":29740,"avatar_url":"https://avatars.githubusercontent.com/u/29740?v=3","gravatar_id":"","url":"https://api.github.com/users/chef","html_url":"https://github.com/chef","followers_url":"https://api.github.com/users/chef/followers","following_url":"https://api.github.com/users/chef/following{/other_user}","gists_url":"https://api.github.com/users/chef/gists{/gist_id}","starred_url":"https://api.github.com/users/chef/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chef/subscriptions","organizations_url":"https://api.github.com/users/chef/orgs","repos_url":"https://api.github.com/users/chef/repos","events_url":"https://api.github.com/users/chef/events{/privacy}","received_events_url":"https://api.github.com/users/chef/received_events","type":"Organization","site_admin":false},"repo":{"id":4080739,"name":"omnibus-ctl","full_name":"chef/omnibus-ctl","owner":{"login":"chef","id":29740,"avatar_url":"https://avatars.githubusercontent.com/u/29740?v=3","gravatar_id":"","url":"https://api.github.com/users/chef","html_url":"https://github.com/chef","followers_url":"https://api.github.com/users/chef/followers","following_url":"https://api.github.com/users/chef/following{/other_user}","gists_url":"https://api.github.com/users/chef/gists{/gist_id}","starred_url":"https://api.github.com/users/chef/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chef/subscriptions","organizations_url":"https://api.github.com/users/chef/orgs","repos_url":"https://api.github.com/users/chef/repos","events_url":"https://api.github.com/users/chef/events{/privacy}","received_events_url":"https://api.github.com/users/chef/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/chef/omnibus-ctl","description":"Provides service control for omnibus packages","fork":false,"url":"https://api.github.com/repos/chef/omnibus-ctl","forks_url":"https://api.github.com/repos/chef/omnibus-ctl/forks","keys_url":"https://api.github.com/repos/chef/omnibus-ctl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/chef/omnibus-ctl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/chef/omnibus-ctl/teams","hooks_url":"https://api.github.com/repos/chef/omnibus-ctl/hooks","issue_events_url":"https://api.github.com/repos/chef/omnibus-ctl/issues/events{/number}","events_url":"https://api.github.com/repos/chef/omnibus-ctl/events","assignees_url":"https://api.github.com/repos/chef/omnibus-ctl/assignees{/user}","branches_url":"https://api.github.com/repos/chef/omnibus-ctl/branches{/branch}","tags_url":"https://api.github.com/repos/chef/omnibus-ctl/tags","blobs_url":"https://api.github.com/repos/chef/omnibus-ctl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/chef/omnibus-ctl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/chef/omnibus-ctl/git/refs{/sha}","trees_url":"https://api.github.com/repos/chef/omnibus-ctl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/chef/omnibus-ctl/statuses/{sha}","languages_url":"https://api.github.com/repos/chef/omnibus-ctl/languages","stargazers_url":"https://api.github.com/repos/chef/omnibus-ctl/stargazers","contributors_url":"https://api.github.com/repos/chef/omnibus-ctl/contributors","subscribers_url":"https://api.github.com/repos/chef/omnibus-ctl/subscribers","subscription_url":"https://api.github.com/repos/chef/omnibus-ctl/subscription","commits_url":"https://api.github.com/repos/chef/omnibus-ctl/commits{/sha}","git_commits_url":"https://api.github.com/repos/chef/omnibus-ctl/git/commits{/sha}","comments_url":"https://api.github.com/repos/chef/omnibus-ctl/comments{/number}","issue_comment_url":"https://api.github.com/repos/chef/omnibus-ctl/issues/comments{/number}","contents_url":"https://api.github.com/repos/chef/omnibus-ctl/contents/{+path}","compare_url":"https://api.github.com/repos/chef/omnibus-ctl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/chef/omnibus-ctl/merges","archive_url":"https://api.github.com/repos/chef/omnibus-ctl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/chef/omnibus-ctl/downloads","issues_url":"https://api.github.com/repos/chef/omnibus-ctl/issues{/number}","pulls_url":"https://api.github.com/repos/chef/omnibus-ctl/pulls{/number}","milestones_url":"https://api.github.com/repos/chef/omnibus-ctl/milestones{/number}","notifications_url":"https://api.github.com/repos/chef/omnibus-ctl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/chef/omnibus-ctl/labels{/name}","releases_url":"https://api.github.com/repos/chef/omnibus-ctl/releases{/id}","created_at":"2012-04-19T22:05:56Z","updated_at":"2015-04-29T15:27:21Z","pushed_at":"2015-08-19T19:58:23Z","git_url":"git://github.com/chef/omnibus-ctl.git","ssh_url":"git@github.com:chef/omnibus-ctl.git","clone_url":"https://github.com/chef/omnibus-ctl.git","svn_url":"https://github.com/chef/omnibus-ctl","homepage":null,"size":682,"stargazers_count":7,"watchers_count":7,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":6,"forks":6,"open_issues":6,"watchers":7,"default_branch":"master"}},"base":{"label":"chef:master","ref":"master","sha":"b0e4c32f51dadb0131ece3edb60261f7ce5482b3","user":{"login":"chef","id":29740,"avatar_url":"https://avatars.githubusercontent.com/u/29740?v=3","gravatar_id":"","url":"https://api.github.com/users/chef","html_url":"https://github.com/chef","followers_url":"https://api.github.com/users/chef/followers","following_url":"https://api.github.com/users/chef/following{/other_user}","gists_url":"https://api.github.com/users/chef/gists{/gist_id}","starred_url":"https://api.github.com/users/chef/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chef/subscriptions","organizations_url":"https://api.github.com/users/chef/orgs","repos_url":"https://api.github.com/users/chef/repos","events_url":"https://api.github.com/users/chef/events{/privacy}","received_events_url":"https://api.github.com/users/chef/received_events","type":"Organization","site_admin":false},"repo":{"id":4080739,"name":"omnibus-ctl","full_name":"chef/omnibus-ctl","owner":{"login":"chef","id":29740,"avatar_url":"https://avatars.githubusercontent.com/u/29740?v=3","gravatar_id":"","url":"https://api.github.com/users/chef","html_url":"https://github.com/chef","followers_url":"https://api.github.com/users/chef/followers","following_url":"https://api.github.com/users/chef/following{/other_user}","gists_url":"https://api.github.com/users/chef/gists{/gist_id}","starred_url":"https://api.github.com/users/chef/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chef/subscriptions","organizations_url":"https://api.github.com/users/chef/orgs","repos_url":"https://api.github.com/users/chef/repos","events_url":"https://api.github.com/users/chef/events{/privacy}","received_events_url":"https://api.github.com/users/chef/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/chef/omnibus-ctl","description":"Provides service control for omnibus packages","fork":false,"url":"https://api.github.com/repos/chef/omnibus-ctl","forks_url":"https://api.github.com/repos/chef/omnibus-ctl/forks","keys_url":"https://api.github.com/repos/chef/omnibus-ctl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/chef/omnibus-ctl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/chef/omnibus-ctl/teams","hooks_url":"https://api.github.com/repos/chef/omnibus-ctl/hooks","issue_events_url":"https://api.github.com/repos/chef/omnibus-ctl/issues/events{/number}","events_url":"https://api.github.com/repos/chef/omnibus-ctl/events","assignees_url":"https://api.github.com/repos/chef/omnibus-ctl/assignees{/user}","branches_url":"https://api.github.com/repos/chef/omnibus-ctl/branches{/branch}","tags_url":"https://api.github.com/repos/chef/omnibus-ctl/tags","blobs_url":"https://api.github.com/repos/chef/omnibus-ctl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/chef/omnibus-ctl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/chef/omnibus-ctl/git/refs{/sha}","trees_url":"https://api.github.com/repos/chef/omnibus-ctl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/chef/omnibus-ctl/statuses/{sha}","languages_url":"https://api.github.com/repos/chef/omnibus-ctl/languages","stargazers_url":"https://api.github.com/repos/chef/omnibus-ctl/stargazers","contributors_url":"https://api.github.com/repos/chef/omnibus-ctl/contributors","subscribers_url":"https://api.github.com/repos/chef/omnibus-ctl/subscribers","subscription_url":"https://api.github.com/repos/chef/omnibus-ctl/subscription","commits_url":"https://api.github.com/repos/chef/omnibus-ctl/commits{/sha}","git_commits_url":"https://api.github.com/repos/chef/omnibus-ctl/git/commits{/sha}","comments_url":"https://api.github.com/repos/chef/omnibus-ctl/comments{/number}","issue_comment_url":"https://api.github.com/repos/chef/omnibus-ctl/issues/comments{/number}","contents_url":"https://api.github.com/repos/chef/omnibus-ctl/contents/{+path}","compare_url":"https://api.github.com/repos/chef/omnibus-ctl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/chef/omnibus-ctl/merges","archive_url":"https://api.github.com/repos/chef/omnibus-ctl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/chef/omnibus-ctl/downloads","issues_url":"https://api.github.com/repos/chef/omnibus-ctl/issues{/number}","pulls_url":"https://api.github.com/repos/chef/omnibus-ctl/pulls{/number}","milestones_url":"https://api.github.com/repos/chef/omnibus-ctl/milestones{/number}","notifications_url":"https://api.github.com/repos/chef/omnibus-ctl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/chef/omnibus-ctl/labels{/name}","releases_url":"https://api.github.com/repos/chef/omnibus-ctl/releases{/id}","created_at":"2012-04-19T22:05:56Z","updated_at":"2015-04-29T15:27:21Z","pushed_at":"2015-08-19T19:58:23Z","git_url":"git://github.com/chef/omnibus-ctl.git","ssh_url":"git@github.com:chef/omnibus-ctl.git","clone_url":"https://github.com/chef/omnibus-ctl.git","svn_url":"https://github.com/chef/omnibus-ctl","homepage":null,"size":682,"stargazers_count":7,"watchers_count":7,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":6,"forks":6,"open_issues":6,"watchers":7,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/chef/omnibus-ctl/pulls/36"},"html":{"href":"https://github.com/chef/omnibus-ctl/pull/36"},"issue":{"href":"https://api.github.com/repos/chef/omnibus-ctl/issues/36"},"comments":{"href":"https://api.github.com/repos/chef/omnibus-ctl/issues/36/comments"},"review_comments":{"href":"https://api.github.com/repos/chef/omnibus-ctl/pulls/36/comments"},"review_comment":{"href":"https://api.github.com/repos/chef/omnibus-ctl/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/chef/omnibus-ctl/pulls/36/commits"},"statuses":{"href":"https://api.github.com/repos/chef/omnibus-ctl/statuses/b38ceb6833db291d968781573504e1a6f4a1264f"}}}}