Sha256: 182a97b27436b698a23a8037b5e62c7bdacacac02f733f500dc036304e5a78cf

Contents?: true

Size: 921 Bytes

Versions: 15

Compression:

Stored size: 921 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
        ''
      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: 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); end

      def do_after(opts); end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
ruby_helm-0.4.0.pre.4 lib/ruby_helm/commands/base.rb
ruby_helm-0.4.0.pre.3 lib/ruby_helm/commands/base.rb
ruby_helm-0.4.0.pre.2 lib/ruby_helm/commands/base.rb
ruby_helm-0.4.0.pre.1 lib/ruby_helm/commands/base.rb
ruby_helm-0.3.0 lib/ruby_helm/commands/base.rb
ruby_helm-0.2.0.pre.10 lib/ruby_helm/commands/base.rb
ruby_helm-0.2.0.pre.9 lib/ruby_helm/commands/base.rb
ruby_helm-0.2.0.pre.8 lib/ruby_helm/commands/base.rb
ruby_helm-0.2.0.pre.7 lib/ruby_helm/commands/base.rb
ruby_helm-0.2.0.pre.6 lib/ruby_helm/commands/base.rb
ruby_helm-0.2.0.pre.5 lib/ruby_helm/commands/base.rb
ruby_helm-0.2.0.pre.4 lib/ruby_helm/commands/base.rb
ruby_helm-0.2.0.pre.3 lib/ruby_helm/commands/base.rb
ruby_helm-0.2.0.pre.2 lib/ruby_helm/commands/base.rb
ruby_helm-0.2.0.pre.1 lib/ruby_helm/commands/base.rb