Sha256: fd211023c53c681f92b7a1f18a95c51f3588372769a62eafd0c9dad3ed40a52b

Contents?: true

Size: 993 Bytes

Versions: 15

Compression:

Stored size: 993 Bytes

Contents

# frozen_string_literal: true

module ConvenientService
  module Examples
    module Standard
      module Gemfile
        module Services
          class RunShell
            include ConvenientService::Standard::Config

            attr_reader :command, :debug

            def initialize(command:, debug: false)
              @command = command
              @debug = debug
            end

            def result
              Services::PrintShellCommand[text: command] if debug

              ##
              # NOTE: When the command exit code is 0, `system` return true, and false otherwise.
              # - https://ruby-doc.org/core-3.1.2/Kernel.html#method-i-system
              # - https://stackoverflow.com/a/37329716/12201472
              #
              if system(command)
                success
              else
                error(message: "#{command} returned non-zero exit code")
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
convenient_service-0.12.0 lib/convenient_service/examples/standard/gemfile/services/run_shell.rb
convenient_service-0.11.0 lib/convenient_service/examples/standard/gemfile/services/run_shell.rb
convenient_service-0.10.1 lib/convenient_service/examples/standard/gemfile/services/run_shell.rb
convenient_service-0.10.0 lib/convenient_service/examples/standard/gemfile/services/run_shell.rb
convenient_service-0.9.0 lib/convenient_service/examples/standard/gemfile/services/run_shell.rb
convenient_service-0.8.0 lib/convenient_service/examples/standard/gemfile/services/run_shell.rb
convenient_service-0.7.0 lib/convenient_service/examples/standard/gemfile/services/run_shell.rb
convenient_service-0.6.0 lib/convenient_service/examples/standard/gemfile/services/run_shell.rb
convenient_service-0.5.0 lib/convenient_service/examples/standard/gemfile/services/run_shell.rb
convenient_service-0.4.0 lib/convenient_service/examples/standard/gemfile/services/run_shell.rb
convenient_service-0.3.1 lib/convenient_service/examples/standard/gemfile/services/run_shell.rb
convenient_service-0.3.0 lib/convenient_service/examples/standard/gemfile/services/run_shell.rb
convenient_service-0.2.1 lib/convenient_service/examples/standard/gemfile/services/run_shell.rb
convenient_service-0.2.0 lib/convenient_service/examples/standard/gemfile/services/run_shell.rb
convenient_service-0.1.0 lib/convenient_service/examples/standard/gemfile/services/run_shell.rb