Class: CLI::Kit::Executor
- Inherits:
-
Object
- Object
- CLI::Kit::Executor
- Defined in:
- lib/cli/kit/executor.rb
Instance Method Summary collapse
-
#call(command, command_name, args) ⇒ Object
: (singleton(CLI::Kit::BaseCommand) command, String command_name, Array args) -> void.
-
#initialize(log_file:) ⇒ Executor
constructor
: (log_file: String) -> void.
Constructor Details
#initialize(log_file:) ⇒ Executor
: (log_file: String) -> void
11 12 13 14 |
# File 'lib/cli/kit/executor.rb', line 11 def initialize(log_file:) FileUtils.mkpath(File.dirname(log_file)) @log_file = log_file end |
Instance Method Details
#call(command, command_name, args) ⇒ Object
: (singleton(CLI::Kit::BaseCommand) command, String command_name, Array args) -> void
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/cli/kit/executor.rb', line 17 def call(command, command_name, args) with_traps do with_logging do |id| command.call(args, command_name) rescue => e begin $stderr.puts "This command ran with ID: #{id}" $stderr.puts 'Please include this information in any issues/report along with relevant logs' rescue SystemCallError # Outputting to stderr is best-effort. Avoid raising another error when outputting debug info so that # we can detect and log the original error, which may even be the source of this error. nil end raise e end end end |