Sha256: 2357a1f00a97317dc5c6e4d55b7ca469337652855fcaf0e0485bd72b32d6c7a0

Contents?: true

Size: 934 Bytes

Versions: 5

Compression:

Stored size: 934 Bytes

Contents

require 'lino'

module RubyEasyRSA
  module Commands
    class Base
      attr_reader :binary

      def initialize(binary: nil)
        @binary = binary || RubyEasyRSA.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)
        builder
      end

      def do_after(opts)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ruby_easy_rsa-0.2.0.pre.8 lib/ruby_easy_rsa/commands/base.rb
ruby_easy_rsa-0.2.0.pre.7 lib/ruby_easy_rsa/commands/base.rb
ruby_easy_rsa-0.2.0.pre.6 lib/ruby_easy_rsa/commands/base.rb
ruby_easy_rsa-0.2.0.pre.5 lib/ruby_easy_rsa/commands/base.rb
ruby_easy_rsa-0.2.0.pre.4 lib/ruby_easy_rsa/commands/base.rb