lib/ruby_fly/commands/status.rb in ruby_fly-0.40.0.pre.4 vs lib/ruby_fly/commands/status.rb in ruby_fly-0.40.0.pre.5
- old
+ new
@@ -9,45 +9,39 @@
module Commands
class Status < Base
include Mixins::Environment
include Mixins::RequiredParams
- def initialize(*args)
- super(*args)
- @stdout = StringIO.new unless
- defined?(@stdout) && @stdout.respond_to?(:string)
- @stderr = StringIO.new unless
- defined?(@stderr) && @stderr.respond_to?(:string)
+ private
+
+ def invocation_option_defaults(_invocation_options)
+ super.merge(capture: %i[stdout stderr])
end
- def configure_command(builder, opts)
- builder = super(builder, opts)
+ def configure_command(initial_builder, parameters)
+ builder = super
builder
.with_subcommand('status') do |sub|
- sub = with_target(sub, opts[:target])
- sub
- end
+ sub = with_target(sub, parameters[:target])
+ sub
+ end
end
- def do_around(opts, &block)
- block.call(opts)
- rescue Open4::SpawnError => e
- raise e unless e.status.exitstatus == 1
+ def do_around(parameters, invocation_options, &block)
+ block.call(parameters, invocation_options)
end
- def do_after(_opts)
- output = stdout.string
- error = stderr.string
+ def process_result(result, _parameters, _invocation_options)
+ output = result[:output]
+ error = result[:error]
return :logged_in if output =~ /logged in successfully/
return :logged_out if error =~ /logged out/
return :session_expired if error =~ /please login again/
return :unknown_target if error =~ /error: unknown target/
:unknown_status
end
-
- private
def required_params
%i[target]
end