Skip to content

Commit 373ac81

Browse files
Pierre Bailletdanielsdeleo
authored andcommitted
. Added plain text output and clever single attribute output
1 parent 473c208 commit 373ac81

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

‎chef/lib/chef/knife.rb‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
require 'mixlib/cli'
2121
require 'chef/mixin/convert_to_class_name'
2222

23+
require 'pp'
24+
2325
class Chef
2426
class Knife
2527
include Mixlib::CLI
@@ -139,6 +141,14 @@ def output(data)
139141
when "yaml"
140142
require 'yaml'
141143
puts YAML::dump(data)
144+
when "text"
145+
# If you were looking for some attribute and there is only one match
146+
# just dump the attribute value
147+
if data.length == 1 and config[:attribute]
148+
puts data.values[0]
149+
else
150+
pp data
151+
end
142152
else
143153
raise ArgumentError, "Unknown output format #{config[:format]}"
144154
end

0 commit comments

Comments
 (0)