diff options
author | Thom May <thom@may.lt> | 2018-01-22 18:15:50 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-22 18:15:50 +0000 |
commit | 9853f36058cc389af9f011dd5e38311293deac68 (patch) | |
tree | a49248b5bb7303071b41cbec16b63e30b7c74acd /lib/chef | |
parent | fc84ad29bf1a365e343b5bb3d4206663269420cc (diff) | |
parent | b46ae663ddf0277c88dea188bffbadb5c4e2fabb (diff) | |
download | chef-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…
Diffstat (limited to 'lib/chef')
-rw-r--r-- | lib/chef/knife/search.rb | 4 |
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 |