mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-04-11 03:00:13 -04:00
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:
20
test/test_option_parser.coffee
Normal file
20
test/test_option_parser.coffee
Normal 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'
|
||||
|
||||
Reference in New Issue
Block a user