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.1.2 lib/eco/cli/scripting/argument.rb
eco-helpers-1.1.1 lib/eco/cli/scripting/argument.rb
eco-helpers-1.0.14 lib/eco/cli/scripting/argument.rb
eco-helpers-1.0.13 lib/eco/cli/scripting/argument.rb
eco-helpers-1.0.12 lib/eco/cli/scripting/argument.rb
eco-helpers-1.0.11 lib/eco/cli/scripting/argument.rb
eco-helpers-1.0.10 lib/eco/cli/scripting/argument.rb
eco-helpers-1.0.9 lib/eco/cli/scripting/argument.rb
eco-helpers-1.0.8 lib/eco/cli/scripting/argument.rb
eco-helpers-1.0.7 lib/eco/cli/scripting/argument.rb
eco-helpers-1.0.6 lib/eco/cli/scripting/argument.rb
eco-helpers-1.0.5 lib/eco/cli/scripting/argument.rb
eco-helpers-1.0.4 lib/eco/cli/scripting/argument.rb
eco-helpers-1.0.3 lib/eco/cli/scripting/argument.rb
eco-helpers-0.9.5 lib/eco/cli/scripting/argument.rb
eco-helpers-1.0.2 lib/eco/cli/scripting/argument.rb
eco-helpers-0.9.4 lib/eco/cli/scripting/argument.rb
eco-helpers-0.9.3 lib/eco/cli/scripting/argument.rb