Class: Brut::CLI::ExecutionResults::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/brut/cli/execution_results.rb

Overview

Base class for all results.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(exit_status:, message: nil) ⇒ Result

Create a new result

command. All other values have command-defined meanings.

Parameters:

  • exit_status (Integer)

    exit status desired for this command. 0 is treated as success by any command that called your

  • message (String|nil) (defaults to: nil)

    a message to explain the results, if relevant.



16
17
18
19
# File 'lib/brut/cli/execution_results.rb', line 16

def initialize(exit_status:,message:nil)
  @exit_status = exit_status
  @message = message
end

Instance Attribute Details

#messageStrting (readonly)

Returns any message provided in the results. Generally nil for successful results.

Returns:

  • (Strting)

    any message provided in the results. Generally nil for successful results.



9
10
11
# File 'lib/brut/cli/execution_results.rb', line 9

def message
  @message
end

Instance Method Details

#ok?true|false

Returns true if the execution of the command succeeded or didn't error.

Returns:

  • (true|false)

    true if the execution of the command succeeded or didn't error



24
25
# File 'lib/brut/cli/execution_results.rb', line 24

def ok?         = @exit_status == 0
# @return [Integer] the exit status

#show_usage?true|false

Returns true if the result means that the user should be show CLI usage in addition to any messaging.

Returns:

  • (true|false)

    true if the result means that the user should be show CLI usage in addition to any messaging.



28
# File 'lib/brut/cli/execution_results.rb', line 28

def show_usage? = false

#stop?true|false

Returns true if execution internal to the command should stop.

Returns:

  • (true|false)

    true if execution internal to the command should stop



22
23
# File 'lib/brut/cli/execution_results.rb', line 22

def stop?       = @exit_status != 0
# @return [true|false] true if the execution of the command succeeded or didn't error

#to_iInteger

Returns the exit status.

Returns:

  • (Integer)

    the exit status



26
27
# File 'lib/brut/cli/execution_results.rb', line 26

def to_i        = @exit_status
# @return [true|false] true if the result means that the user should be show CLI usage in addition to any messaging.