Sha256: 61d1f5f4f7d491fbaaf644205e680d38623e84d96f42a8d8b0fc0bc75051f5fd

Contents?: true

Size: 793 Bytes

Versions: 117

Compression:

Stored size: 793 Bytes

Contents

module Eco
  class CLI
    class Scripting
      class Argument

        attr_reader :key

        class << self
          def is_modifier?(value)
           value&.start_with?("-")
          end
        end

        def initialize(key, with_param: false)
          @key        = key
          @with_param = !!with_param
        end

        def args_slice(*args)
          #pp "known arg '#{key}' => included? #{args.include?(key)}"
          return args unless args.include?(key)
          i = args.index(key)
          j = with_param?? i+1 : i
          args - args.slice(i..j)
        end

        def with_param!
          @with_param = true
        end

        def with_param?
          @with_param
        end
        
      end
    end
  end
end

Version data entries

117 entries across 117 versions & 1 rubygems

Version Path
eco-helpers-2.0.45 lib/eco/cli/scripting/argument.rb
eco-helpers-2.0.44 lib/eco/cli/scripting/argument.rb
eco-helpers-2.0.43 lib/eco/cli/scripting/argument.rb
eco-helpers-2.0.42 lib/eco/cli/scripting/argument.rb
eco-helpers-2.0.41 lib/eco/cli/scripting/argument.rb
eco-helpers-2.0.40 lib/eco/cli/scripting/argument.rb
eco-helpers-2.0.39 lib/eco/cli/scripting/argument.rb
eco-helpers-2.0.38 lib/eco/cli/scripting/argument.rb
eco-helpers-2.0.37 lib/eco/cli/scripting/argument.rb
eco-helpers-2.0.36 lib/eco/cli/scripting/argument.rb
eco-helpers-2.0.35 lib/eco/cli/scripting/argument.rb
eco-helpers-2.0.34 lib/eco/cli/scripting/argument.rb
eco-helpers-2.0.33 lib/eco/cli/scripting/argument.rb
eco-helpers-2.0.32 lib/eco/cli/scripting/argument.rb
eco-helpers-2.0.31 lib/eco/cli/scripting/argument.rb
eco-helpers-2.0.30 lib/eco/cli/scripting/argument.rb
eco-helpers-2.0.29 lib/eco/cli/scripting/argument.rb
eco-helpers-2.0.28 lib/eco/cli/scripting/argument.rb
eco-helpers-2.0.27 lib/eco/cli/scripting/argument.rb
eco-helpers-2.0.26 lib/eco/cli/scripting/argument.rb