summaryrefslogtreecommitdiff
path: root/lib/chef/knife/core/generic_presenter.rb
diff options
context:
space:
mode:
authorRanjib Dey <ranjib@pagerduty.com>2013-04-11 20:54:22 -0700
committerBryan McLellan <btm@opscode.com>2013-05-24 10:27:03 -0700
commit4133160972a9972a9a062579504faa40eaa4c8db (patch)
treef74b21723c15cb0abc0420f16ef1ee50662e3120 /lib/chef/knife/core/generic_presenter.rb
parent1e2dd728f8d9ad724aa2980d5fb15c2e26d6bed8 (diff)
downloadchef-4133160972a9972a9a062579504faa40eaa4c8db.tar.gz
multi attribute return
Diffstat (limited to 'lib/chef/knife/core/generic_presenter.rb')
-rw-r--r--lib/chef/knife/core/generic_presenter.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/chef/knife/core/generic_presenter.rb b/lib/chef/knife/core/generic_presenter.rb
index 0866f10147..518252c7b8 100644
--- a/lib/chef/knife/core/generic_presenter.rb
+++ b/lib/chef/knife/core/generic_presenter.rb
@@ -22,6 +22,22 @@ class Chef
class Knife
module Core
+ # Allows includer knife commands to return multiple attribute:
+ # e.g knife node show NAME -a ATTR1 -a ATTR2
+ module MultiAttributeRetrunOption
+ # :nodoc:
+ def self.included(includer)
+ includer.class_eval do
+ @attrs_to_show = []
+ option :attribute,
+ :short => "-a ATTR1 [-a ATTR2]",
+ :long => "--attribute ATTR1 [--attribute ATTR2] ",
+ :proc => lambda {|val| @attrs_to_show << val},
+ :description => "Show one or more attributes"
+ end
+ end
+ end
+
#==Chef::Knife::Core::GenericPresenter
# The base presenter class for displaying structured data in knife commands.
# This is not an abstract base class, and it is suitable for displaying