summaryrefslogtreecommitdiff
path: root/lib/chef/knife/xargs.rb
diff options
context:
space:
mode:
authorJohn Keiser <jkeiser@opscode.com>2013-04-05 23:15:35 -0700
committerJohn Keiser <jkeiser@opscode.com>2013-06-07 13:12:30 -0700
commit9407da63cbe0416c0c5f5ffe96b9c69fc04d1358 (patch)
tree041c623bb6607baa615fac014924ffa3c102c88e /lib/chef/knife/xargs.rb
parent1eacecda5bd07ba45f38f291d73cc3708ca82b82 (diff)
downloadchef-9407da63cbe0416c0c5f5ffe96b9c69fc04d1358.tar.gz
Add xargs -t to print command lines
Diffstat (limited to 'lib/chef/knife/xargs.rb')
-rw-r--r--lib/chef/knife/xargs.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/chef/knife/xargs.rb b/lib/chef/knife/xargs.rb
index 46471f2252..c47ba00baf 100644
--- a/lib/chef/knife/xargs.rb
+++ b/lib/chef/knife/xargs.rb
@@ -54,6 +54,10 @@ class Chef
:short => '-s LENGTH',
:description => "Maximum size of command line, in characters"
+ option :verbose_commands,
+ :short => '-t',
+ :description => "Print command to be run on the command line"
+
def run
error = false
# Get the matches (recursively)
@@ -193,9 +197,12 @@ class Chef
return error if error && tempfiles.size == 0
# Run the command
- output sub_filenames(command, tempfiles)
+ if config[:verbose_commands] || Chef::Config[:verbosity] && Chef::Config[:verbosity] >= 1
+ output sub_filenames(command, tempfiles)
+ end
command_output = `#{command}`
command_output = sub_filenames(command_output, tempfiles)
+ output command_output
# Check if the output is different
tempfiles.each_pair do |tempfile, file|