Sha256: 93b3c059ec11b696953d824f4596b5d4115d65c7ba837239507a42530b8e3ec9

Contents?: true

Size: 783 Bytes

Versions: 78

Compression:

Stored size: 783 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

78 entries across 78 versions & 1 rubygems

Version Path
eco-helpers-1.3.12 lib/eco/cli/scripting/argument.rb
eco-helpers-1.3.11 lib/eco/cli/scripting/argument.rb
eco-helpers-1.3.10 lib/eco/cli/scripting/argument.rb
eco-helpers-1.3.9 lib/eco/cli/scripting/argument.rb
eco-helpers-1.3.8 lib/eco/cli/scripting/argument.rb
eco-helpers-1.3.7 lib/eco/cli/scripting/argument.rb
eco-helpers-1.3.6 lib/eco/cli/scripting/argument.rb
eco-helpers-1.3.5 lib/eco/cli/scripting/argument.rb
eco-helpers-1.3.4 lib/eco/cli/scripting/argument.rb
eco-helpers-1.3.3 lib/eco/cli/scripting/argument.rb
eco-helpers-1.3.2 lib/eco/cli/scripting/argument.rb
eco-helpers-1.3.1 lib/eco/cli/scripting/argument.rb
eco-helpers-1.2.2 lib/eco/cli/scripting/argument.rb
eco-helpers-1.2.1 lib/eco/cli/scripting/argument.rb
eco-helpers-1.1.8 lib/eco/cli/scripting/argument.rb
eco-helpers-1.1.7 lib/eco/cli/scripting/argument.rb
eco-helpers-1.1.6 lib/eco/cli/scripting/argument.rb
eco-helpers-1.1.5 lib/eco/cli/scripting/argument.rb
eco-helpers-1.1.4 lib/eco/cli/scripting/argument.rb
eco-helpers-1.1.3 lib/eco/cli/scripting/argument.rb