fixing optparse to behave nicely in the presence of hashbangs -- stop parsing after the first non-option argument, and pass the rest along -- and adding an OptionParser test.

This commit is contained in:
Jeremy Ashkenas
2010-07-11 09:57:42 -04:00
parent 3d6cdfa636
commit 2a7a26482a
5 changed files with 44 additions and 16 deletions

View File

@@ -0,0 +1,20 @@
# Ensure that the OptionParser handles arguments correctly.
{OptionParser}: require './../lib/optparse'
opt: new OptionParser [
['-r', '--required [DIR]', 'desc required']
['-o', '--optional', 'desc optional']
]
result: opt.parse ['one', 'two', 'three', '-r', 'dir']
ok result.arguments.length is 5
ok result.arguments[3] is '-r'
result: opt.parse ['--optional', '-r', 'folder', 'one', 'two']
ok result.optional is true
ok result.required is 'folder'
ok result.arguments.join(' ') is 'folder one two'