Skip to content

Instantly share code, notes, and snippets.

@kevinrutherford
Created May 6, 2009 20:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevinrutherford/107726 to your computer and use it in GitHub Desktop.
Save kevinrutherford/107726 to your computer and use it in GitHub Desktop.
def parse(arg, argv, &error)
if !(val = arg) and (argv.empty? or /\A-/ =~ (val = argv[0])) # should count as 2
return nil, block, nil
end
opt = (val = parse_arg(val, &error))[1] # counts as 1; should count as 2
val = conv_arg(*val)
if opt and !arg # counts as 1; should count as 2 (or 3?)
argv.shift
else
val[0] = nil
end
val
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment