Sha256: c91ce974d7b524cf507bc2b759de1dbe07c94ad9935c9d7dcc4d77e939d59466

Contents?: true

Size: 784 Bytes

Versions: 17

Compression:

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

17 entries across 17 versions & 1 rubygems

Version Path
eco-helpers-3.0.21 lib/eco/cli/scripting/argument.rb
eco-helpers-3.0.20 lib/eco/cli/scripting/argument.rb
eco-helpers-3.0.19 lib/eco/cli/scripting/argument.rb
eco-helpers-3.0.18 lib/eco/cli/scripting/argument.rb
eco-helpers-3.0.17 lib/eco/cli/scripting/argument.rb
eco-helpers-3.0.16 lib/eco/cli/scripting/argument.rb
eco-helpers-3.0.15 lib/eco/cli/scripting/argument.rb
eco-helpers-3.0.14 lib/eco/cli/scripting/argument.rb
eco-helpers-3.0.13 lib/eco/cli/scripting/argument.rb
eco-helpers-3.0.12 lib/eco/cli/scripting/argument.rb
eco-helpers-3.0.11 lib/eco/cli/scripting/argument.rb
eco-helpers-3.0.10 lib/eco/cli/scripting/argument.rb
eco-helpers-3.0.9 lib/eco/cli/scripting/argument.rb
eco-helpers-3.0.8 lib/eco/cli/scripting/argument.rb
eco-helpers-3.0.7 lib/eco/cli/scripting/argument.rb
eco-helpers-3.0.6 lib/eco/cli/scripting/argument.rb
eco-helpers-3.0.5 lib/eco/cli/scripting/argument.rb