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.4 lib/eco/cli/scripting/argument.rb
eco-helpers-2.0.3 lib/eco/cli/scripting/argument.rb
eco-helpers-2.0.2 lib/eco/cli/scripting/argument.rb
eco-helpers-1.5.15 lib/eco/cli/scripting/argument.rb
eco-helpers-1.5.14 lib/eco/cli/scripting/argument.rb
eco-helpers-1.5.13 lib/eco/cli/scripting/argument.rb
eco-helpers-1.5.12 lib/eco/cli/scripting/argument.rb
eco-helpers-1.5.11 lib/eco/cli/scripting/argument.rb
eco-helpers-1.5.10 lib/eco/cli/scripting/argument.rb
eco-helpers-1.5.9 lib/eco/cli/scripting/argument.rb
eco-helpers-1.5.8 lib/eco/cli/scripting/argument.rb
eco-helpers-1.5.7 lib/eco/cli/scripting/argument.rb
eco-helpers-1.5.6 lib/eco/cli/scripting/argument.rb
eco-helpers-1.5.5 lib/eco/cli/scripting/argument.rb
eco-helpers-1.5.4 lib/eco/cli/scripting/argument.rb
eco-helpers-1.5.3 lib/eco/cli/scripting/argument.rb
eco-helpers-1.5.2 lib/eco/cli/scripting/argument.rb