Sha256: 9d94eab990a7e250ea3f9825536ae0ef20f83035108c8a5c0816155b17cfe52b

Contents?: true

Size: 1.05 KB

Versions: 16

Compression:

Stored size: 1.05 KB

Contents

module Eco
  module Common
    class MetaThor
      class CommandUnit
        class << self

        end

        attr_reader :group, :index
        attr_reader :pipe
        attr_reader :args, :source_args
        attr_accessor :output

        def initialize(args:, group:, index:)
          @source_args = args.dup || []
          @args = @source_args
          @args = @args.slice(1..-1) if Pipe.piped?(@source_args)
          @pipe = Pipe.new(command: self) if Pipe.piped?(@source_args)

          @group = group
          @index = index
        end

        def piped?
          !!@pipe
        end

        def input
          pipe&.input
        end

        def args
          arguments = @args.dup
          arguments = yield(arguments) if block_given?
          arguments
        end

        def piped_args
          args.tap do |arguments|
            arguments = yield(arguments) if block_given?
            arguments.push(pipe.input.as_input_option) if piped?
          end
        end

      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
eco-helpers-0.8.3 lib/eco/common/meta_thor/command_unit.rb
eco-helpers-0.8.2 lib/eco/common/meta_thor/command_unit.rb
eco-helpers-0.8.1 lib/eco/common/meta_thor/command_unit.rb
eco-helpers-0.7.2 lib/eco/common/meta_thor/command_unit.rb
eco-helpers-0.7.1 lib/eco/common/meta_thor/command_unit.rb
eco-helpers-0.6.17 lib/eco/common/meta_thor/command_unit.rb
eco-helpers-0.6.16 lib/eco/common/meta_thor/command_unit.rb
eco-helpers-0.6.15 lib/eco/common/meta_thor/command_unit.rb
eco-helpers-0.6.13 lib/eco/common/meta_thor/command_unit.rb
eco-helpers-0.6.12 lib/eco/common/meta_thor/command_unit.rb
eco-helpers-0.6.11 lib/eco/common/meta_thor/command_unit.rb
eco-helpers-0.6.9 lib/eco/common/meta_thor/command_unit.rb
eco-helpers-0.6.8 lib/eco/common/meta_thor/command_unit.rb
eco-helpers-0.6.7 lib/eco/common/meta_thor/command_unit.rb
eco-helpers-0.6.6 lib/eco/common/meta_thor/command_unit.rb
eco-helpers-0.6.5 lib/eco/common/meta_thor/command_unit.rb