Is there any way to specify sketchbook folder as a command-line option?

This way I can isolate different versions of libraries for different projects and test conditions. Right now I'm just manually switching back and forth.

Yes, you can use the --pref option to set the sketchbook location in the sketchbook.path property, then save it using the --save-prefs option. For example, if you wanted to set your sketchbook to E:\foobar, the Windows command (use arduino_debug instead of arduino on Windows) would look like this:

./arduino_debug --pref sketchbook.path=E:\deleteme --save-prefs

that only sets the preference. It doesn't start the IDE. you would need to run the arduino command after that to start the IDE.

More information: