From 92ab2ec1fecb62078dfc8200cffb2440f2c6b300 Mon Sep 17 00:00:00 2001 From: elijah Date: Fri, 19 Aug 2016 12:19:54 -0700 Subject: leap_cli: better arguments to 'leap run' --- lib/leap_cli/commands/run.rb | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/leap_cli/commands/run.rb b/lib/leap_cli/commands/run.rb index 52121035..a12af60e 100644 --- a/lib/leap_cli/commands/run.rb +++ b/lib/leap_cli/commands/run.rb @@ -1,9 +1,10 @@ module LeapCli; module Commands - desc 'runs the specified command on each node.' - arg_name 'FILTER' + desc 'Run a shell command remotely' + long_desc "Runs the specified command COMMAND on each node in the FILTER set. " + + "For example, `leap run 'uname -a' webapp`" + arg_name 'COMMAND FILTER' command :run do |c| - c.flag 'cmd', :arg_name => 'COMMAND', :desc => 'The command to run.' c.switch 'stream', :default => false, :desc => 'If set, stream the output as it arrives. (default: --no-stream)' c.flag 'port', :arg_name => 'SSH_PORT', :desc => 'Override default SSH port used when trying to connect to the server.' c.action do |global, options, args| @@ -15,8 +16,10 @@ module LeapCli; module Commands def run_shell_command(global, options, args) require 'leap_cli/ssh' - cmd = global[:force] ? options[:cmd] : LeapCli::SSH::Options.sanitize_command(options[:cmd]) - nodes = manager.filter!(args) + cmd = args[0] + filter = args[1..-1] + cmd = global[:force] ? cmd : LeapCli::SSH::Options.sanitize_command(cmd) + nodes = manager.filter!(filter) if options[:stream] stream_command(nodes, cmd, options) else -- cgit v1.2.3