Sha256: 1eacddb3f7d6162377fa80fa5494bbd37b07fd194c7dd41a22c4a3107b70cce9

Contents?: true

Size: 531 Bytes

Versions: 14

Compression:

Stored size: 531 Bytes

Contents

# frozen-string-literal: true

module Rodbot
  class CLI
    class Command < Dry::CLI::Command
      option :backtrace, type: :boolean, default: false, desc: "Dump backtrace on errors"

      def call(backtrace:, **args)
        rescued_call(**args)
      rescue => error
        error(error.message) do
          raise error if backtrace
        end
      end

      private

      def error(message)
        STDERR.puts "ERROR: command failed: #{message}"
        yield if block_given?
        exit 1
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
rodbot-0.4.5 lib/rodbot/cli/command.rb
rodbot-0.4.4 lib/rodbot/cli/command.rb
rodbot-0.4.3 lib/rodbot/cli/command.rb
rodbot-0.4.2 lib/rodbot/cli/command.rb
rodbot-0.4.1 lib/rodbot/cli/command.rb
rodbot-0.4.0 lib/rodbot/cli/command.rb
rodbot-0.3.4 lib/rodbot/cli/command.rb
rodbot-0.3.3 lib/rodbot/cli/command.rb
rodbot-0.3.2 lib/rodbot/cli/command.rb
rodbot-0.3.1 lib/rodbot/cli/command.rb
rodbot-0.3.0 lib/rodbot/cli/command.rb
rodbot-0.2.0 lib/rodbot/cli/command.rb
rodbot-0.1.1 lib/rodbot/cli/command.rb
rodbot-0.1.0 lib/rodbot/cli/command.rb