summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThom May <thom@may.lt>2018-01-22 18:15:50 +0000
committerGitHub <noreply@github.com>2018-01-22 18:15:50 +0000
commit9853f36058cc389af9f011dd5e38311293deac68 (patch)
treea49248b5bb7303071b41cbec16b63e30b7c74acd
parentfc84ad29bf1a365e343b5bb3d4206663269420cc (diff)
parentb46ae663ddf0277c88dea188bffbadb5c4e2fabb (diff)
downloadchef-9853f36058cc389af9f011dd5e38311293deac68.tar.gz
Merge pull request #6742 from zanecodes/fix_knife_id_only_formatting
Prevent knife search --id-only from outputting IDs in the same format…
-rw-r--r--lib/chef/knife/search.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/chef/knife/search.rb b/lib/chef/knife/search.rb
index 2a68ec5108..94c33aa594 100644
--- a/lib/chef/knife/search.rb
+++ b/lib/chef/knife/search.rb
@@ -98,7 +98,9 @@ class Chef
begin
q.search(@type, @query, search_args) do |item|
formatted_item = Hash.new
- if item.is_a?(Hash)
+ if config[:id_only]
+ formatted_item = format_for_display({ "id" => item["__display_name"] })
+ elsif item.is_a?(Hash)
# doing a little magic here to set the correct name
formatted_item[item["__display_name"]] = item.reject { |k| k == "__display_name" }
else