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-3.0.4 lib/eco/cli/scripting/argument.rb
eco-helpers-3.0.3 lib/eco/cli/scripting/argument.rb
eco-helpers-3.0.2 lib/eco/cli/scripting/argument.rb
eco-helpers-3.0.1 lib/eco/cli/scripting/argument.rb
eco-helpers-3.0.0 lib/eco/cli/scripting/argument.rb
eco-helpers-2.7.25 lib/eco/cli/scripting/argument.rb
eco-helpers-2.7.24 lib/eco/cli/scripting/argument.rb
eco-helpers-2.7.23 lib/eco/cli/scripting/argument.rb
eco-helpers-2.7.22 lib/eco/cli/scripting/argument.rb
eco-helpers-2.7.21 lib/eco/cli/scripting/argument.rb
eco-helpers-2.7.20 lib/eco/cli/scripting/argument.rb
eco-helpers-2.7.19 lib/eco/cli/scripting/argument.rb
eco-helpers-2.7.18 lib/eco/cli/scripting/argument.rb
eco-helpers-2.7.17 lib/eco/cli/scripting/argument.rb
eco-helpers-2.7.16 lib/eco/cli/scripting/argument.rb
eco-helpers-2.7.15 lib/eco/cli/scripting/argument.rb
eco-helpers-2.7.14 lib/eco/cli/scripting/argument.rb
eco-helpers-2.7.13 lib/eco/cli/scripting/argument.rb
eco-helpers-2.7.12 lib/eco/cli/scripting/argument.rb
eco-helpers-2.7.4 lib/eco/cli/scripting/argument.rb