Sha256: aaac4ab73f86cef95b8a4bef48ceaeea6f2c8a0c92660ec28c1f5dd6ac2c7577

Contents?: true

Size: 902 Bytes

Versions: 5

Compression:

Stored size: 902 Bytes

Contents

# frozen_string_literal: true

require 'lino'

module RubyHelm
  module Commands
    class Base
      attr_reader :binary

      def initialize(binary: nil)
        @binary = binary || RubyHelm.configuration.binary
      end

      def stdin
        nil
      end

      def stdout
        $stdout
      end

      def stderr
        $stderr
      end

      def execute(opts = {})
        builder = instantiate_builder

        do_before(opts)
        configure_command(builder, opts)
          .build
          .execute(
            stdin:,
            stdout:,
            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); end

      def do_after(opts); end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ruby_helm-0.6.0.pre.2 lib/ruby_helm/commands/base.rb
ruby_helm-0.6.0.pre.1 lib/ruby_helm/commands/base.rb
ruby_helm-0.5.0 lib/ruby_helm/commands/base.rb
ruby_helm-0.4.0.pre.6 lib/ruby_helm/commands/base.rb
ruby_helm-0.4.0.pre.5 lib/ruby_helm/commands/base.rb