Sha256: 29e33ccc4eeee4f5c066337ad5af5eb905adfdf5695d512a77f9f73fd297f883

Contents?: true

Size: 916 Bytes

Versions: 8

Compression:

Stored size: 916 Bytes

Contents

# frozen_string_literal: true

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 = {})
        do_before(opts)
        configure_command(instantiate_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(_); end

      def configure_command(builder, _opts)
        builder
      end

      def do_after(_); end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ruby_easy_rsa-0.12.0.pre.4 lib/ruby_easy_rsa/commands/base.rb
ruby_easy_rsa-0.12.0.pre.3 lib/ruby_easy_rsa/commands/base.rb
ruby_easy_rsa-0.12.0.pre.2 lib/ruby_easy_rsa/commands/base.rb
ruby_easy_rsa-0.12.0.pre.1 lib/ruby_easy_rsa/commands/base.rb
ruby_easy_rsa-0.11.0 lib/ruby_easy_rsa/commands/base.rb
ruby_easy_rsa-0.10.0.pre.10 lib/ruby_easy_rsa/commands/base.rb
ruby_easy_rsa-0.10.0.pre.9 lib/ruby_easy_rsa/commands/base.rb
ruby_easy_rsa-0.10.0.pre.8 lib/ruby_easy_rsa/commands/base.rb