Sha256: 4bb2999642218fe16ccebdc826208633e03694c60c542f3813af046e5b805f15

Contents?: true

Size: 924 Bytes

Versions: 4

Compression:

Stored size: 924 Bytes

Contents

# frozen_string_literal: true

require 'eac_ruby_utils/core_ext'
require 'eac_ruby_utils/envs/base_command'

module EacRubyUtils
  module Envs
    class CompositeCommand
      include ::EacRubyUtils::Envs::BaseCommand

      enable_listable
      lists.add_string :operator, '&&' => :and, ';' => :before, '||' => :or, '|' => :pipe

      common_constructor :operator, :left_command, :right_command do
        self.operator = self.class.lists.operator.value_validate!(operator.to_s)
      end

      # @return [EacRubyUtils::Envs::BaseEnv]
      delegate :env, to: :left_command

      # @return [String]
      def command_line_without_env(_options = {})
        ::Shellwords.join(['bash', '-c', bash_command])
      end

      # @return [String]
      def bash_command
        ['set', '-euo', 'pipefail', OPERATOR_BEFORE, left_command.command, operator,
         right_command.command].join(' ')
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
eac_tools-0.48.0 sub/eac_ruby_utils/lib/eac_ruby_utils/envs/composite_command.rb
eac_tools-0.47.2 sub/eac_ruby_utils/lib/eac_ruby_utils/envs/composite_command.rb
eac_ruby_utils-0.109.0 lib/eac_ruby_utils/envs/composite_command.rb
eac_tools-0.47.1 sub/eac_ruby_utils/lib/eac_ruby_utils/envs/composite_command.rb