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