Sha256: cb99b65095486bd11903525f30597b0b16abaa26461e0fa019d36d64c4231b4b

Contents?: true

Size: 995 Bytes

Versions: 2

Compression:

Stored size: 995 Bytes

Contents

require 'lino'

module RubyFly
  module Commands
    class Base
      attr_reader :binary, :stdin, :stdout, :stderr

      def initialize(binary: nil)
        @binary = binary || RubyFly.configuration.binary
        @stdin = stdin || RubyFly.configuration.stdin
        @stdout = stdout || RubyFly.configuration.stdout
        @stderr = stderr || RubyFly.configuration.stderr
      end

      def execute(opts = {})
        builder = instantiate_builder

        do_before(opts)
        configure_command(builder, opts)
            .build
            .execute(
                stdin: stdin,
                stdout: stdout,
                stderr: stderr)
        do_after(opts)
      end

      def instantiate_builder
        Lino::CommandLineBuilder
            .for_command(binary)
            .with_option_separator('=')
      end

      def do_before(opts)
      end

      def configure_command(builder, opts)
        builder
      end

      def do_after(opts)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ruby_fly-0.29.0 lib/ruby_fly/commands/base.rb
ruby_fly-0.28.0.pre.1 lib/ruby_fly/commands/base.rb