How to get the non-option content when use OptionParser?

Following is a example:

$: test_command -a 'aaa' -b 'bbb' content
$: test_command content -a 'aaa' -b 'bbb'
$: test_command -a 'aaa' content -b 'bbb'

I want to get the content for above all cases, is there a robust way to do this use OptionParser?

Thanks

OptionParser#parse removes all items that have been parsed as arguments from the argument list. content would be left in the arguments list.
Alternatively, you can also use OptionParser#unknown_args for this.

2 Likes