Sha256: aac975be2bf63fcb98591ad3a96162cb56731abc450e2d9100185ef4344ae4f2

Contents?: true

Size: 706 Bytes

Versions: 11

Compression:

Stored size: 706 Bytes

Contents

module ArgsParser
  class Parser

    def parse_style_default(argv)
      k = nil
      is_key = /^-+([^-\s]+)$/
      argv.each_with_index do |arg, index|
        unless k
          if arg =~ is_key
            k = arg.scan(is_key)[0][0].strip.to_sym
            k = aliases[k]  if aliases[k]
          else
            self.argv.push arg
          end
        else
          if arg =~ is_key
            params[k][:value] = true
            k = arg.scan(is_key)[0][0].strip.to_sym
            k = aliases[k]  if aliases[k]
          else
            params[k][:value] = arg
            k = nil
          end
        end
      end
      if k
        params[k][:value] = true
      end
    end

  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
args_parser-0.1.6 lib/args_parser/styles/default.rb
args_parser-0.1.5 lib/args_parser/styles/default.rb
args_parser-0.1.4 lib/args_parser/styles/default.rb
args_parser-0.1.3 lib/args_parser/styles/default.rb
args_parser-0.1.2 lib/args_parser/styles/default.rb
args_parser-0.1.1 lib/args_parser/styles/default.rb
args_parser-0.1.0 lib/args_parser/styles/default.rb
args_parser-0.0.10 lib/args_parser/styles/default.rb
args_parser-0.0.9 lib/args_parser/styles/default.rb
args_parser-0.0.8 lib/args_parser/styles/default.rb
args_parser-0.0.7 lib/args_parser/styles/default.rb