diff options
author | jkeiser <jkeiser@opscode.com> | 2012-12-24 10:47:18 -0800 |
---|---|---|
committer | John Keiser <jkeiser@opscode.com> | 2013-06-07 13:12:13 -0700 |
commit | 0c34d3914c826a2f139a312ece9bad4a78c51cac (patch) | |
tree | 86a85c777af23bde47f89e5d80a547c43066d54d /lib/chef/knife/list.rb | |
parent | e6c3b3f2d7bdbfad2b0421d65e782b165b7e06a2 (diff) | |
download | chef-0c34d3914c826a2f139a312ece9bad4a78c51cac.tar.gz |
Add -1 parameter for one-column list output
Diffstat (limited to 'lib/chef/knife/list.rb')
-rw-r--r-- | lib/chef/knife/list.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/chef/knife/list.rb b/lib/chef/knife/list.rb index 6702620b5e..04615fa121 100644 --- a/lib/chef/knife/list.rb +++ b/lib/chef/knife/list.rb @@ -24,6 +24,10 @@ class Chef :long => '--flat', :boolean => true, :description => "Show a list of filenames rather than the prettified ls-like output normally produced" + option :one_column, + :short => '-1', + :boolean => true, + :description => "Show only one column of results" def run patterns = name_args.length == 0 ? [""] : name_args @@ -107,7 +111,11 @@ class Chef print_space = results.map { |result| result.length }.max + 2 # TODO: tput cols is not cross platform - columns = stdout.isatty ? Integer(`tput cols`) : 0 + if config[:one_column] || !stdout.isatty + columns = 0 + else + columns = Integer(`tput cols`) + end current_line = '' results.each do |result| if current_line.length > 0 && current_line.length + print_space > columns |