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
-
#initialize(log_file:) ⇒ Executor
constructor
A new instance of Executor.
Constructor Details
#initialize(log_file:) ⇒ Executor
Returns a new instance of Executor.
8 9 10 11 |
# File 'lib/cli/kit/executor.rb', line 8 def initialize(log_file:) FileUtils.mkpath(File.dirname(log_file)) @log_file = log_file end |
Instance Method Details
#call(command, command_name, args) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/cli/kit/executor.rb', line 13 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 |