summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel DeLeo <dan@opscode.com>2011-04-11 22:00:42 -0700
committerDaniel DeLeo <dan@opscode.com>2011-04-11 22:00:42 -0700
commit0b134c47310c25c755a5e7853a02773e0d269c09 (patch)
tree8fc6b179516028e45f0dcf879d24565e0e9c2ae9
parentd7084549b302c1df8ef8ea6a3a22ab491c256eea (diff)
downloadchef-0b134c47310c25c755a5e7853a02773e0d269c09.tar.gz
nicer UX for cookbook bulk delete
-rw-r--r--chef/lib/chef/knife/cookbook_bulk_delete.rb16
-rw-r--r--chef/spec/unit/knife/cookbook_bulk_delete_spec.rb3
2 files changed, 15 insertions, 4 deletions
diff --git a/chef/lib/chef/knife/cookbook_bulk_delete.rb b/chef/lib/chef/knife/cookbook_bulk_delete.rb
index 6463bf5152..f8ad74d856 100644
--- a/chef/lib/chef/knife/cookbook_bulk_delete.rb
+++ b/chef/lib/chef/knife/cookbook_bulk_delete.rb
@@ -43,11 +43,21 @@ class Chef
all_cookbooks = Chef::CookbookVersion.list
cookbooks_names = all_cookbooks.keys.grep(regex)
cookbooks_to_delete = cookbooks_names.inject({}) { |hash, name| hash[name] = all_cookbooks[name];hash }
- output(format_list_for_display(cookbooks_to_delete))
+ ui.msg "All versions of the following cookbooks will be deleted:"
+ ui.msg ""
+ ui.msg ui.list(cookbooks_to_delete.keys.sort, :columns_down)
+ ui.msg ""
- ui.confirm("Do you really want to delete these cookbooks? All versions will be deleted. (Y/N) ", false)
+ unless config[:yes]
+ ui.confirm("Do you really want to delete these cookbooks? (Y/N) ", false)
+
+ if config[:purge]
+ ui.msg("Files that are common to multiple cookbooks are shared, so purging the files may break other cookbooks.")
+ ui.confirm("Are you sure you want to purge files instead of just deleting the cookbooks")
+ end
+ ui.msg ""
+ end
- ui.confirm("Files that are common to multiple cookbooks are shared, so purging the files may disable other cookbooks. Are you sure you want to purge files instead of just deleting the cookbooks") if config[:purge]
cookbooks_names.each do |cookbook_name|
versions = rest.get_rest("cookbooks/#{cookbook_name}")[cookbook_name]["versions"].map {|v| v["version"]}.flatten
diff --git a/chef/spec/unit/knife/cookbook_bulk_delete_spec.rb b/chef/spec/unit/knife/cookbook_bulk_delete_spec.rb
index b3f788cdc8..e3392a9ee8 100644
--- a/chef/spec/unit/knife/cookbook_bulk_delete_spec.rb
+++ b/chef/spec/unit/knife/cookbook_bulk_delete_spec.rb
@@ -55,8 +55,9 @@ describe Chef::Knife::CookbookBulkDelete do
end
it "should print the cookbooks you are about to delete" do
- @knife.should_receive(:output).with(@knife.format_list_for_display(@cookbooks))
+ expected = @knife.ui.list(@cookbooks.keys.sort, :columns_down)
@knife.run
+ @stdout.string.should match(/#{expected}/)
end
it "should confirm you really want to delete them" do