I participated in the aforementioned discussion on comp.sys.mac.system and supplied the details on how the command syntax worked.
Thanks to a hint from Wes Groleau we spotted the -W argument to the open command, which tells the open command to wait until the application quits before the open command itself terminates.
The -a argument to the open command means "the next parameter is the name of the application to open". Without -a, the next parameter is interpreted as the pathname of a folder, document or application to open. (If a document is specified, the standard LaunchServices mechanisms are used to determine the default application to launch.)
If you open an application using this form:
open -W ThisApp.app
the open command expects to find ThisApp.app in the current folder. It won't look in other folders, such as the Applications folder. The correct syntax here would typically be:
open -W /Applications/ThisApp.app
If you use the -a option, the next parameter is interpreted as the name of an application, and the open command looks for the application in standard places like the Applications folder. You also don't need to enter the .app suffix (but it will work either way).
You can also compress the options slightly, specifying -W and -a in a single parameter.
Thus the shortest form of the whole command would be:
caffeinate -i open -Wa ThisApp
(assuming ThisApp is the name of an application in your Applications folder).
As to the question of how to have caffeinate always take effect while a target application is running: two general methods occur to me.
(a) Rather than launching the target application directly, write an AppleScript or Automator script saved as an application, which launches the target application via caffeinate. The script application would remain running unti you quit the target application.
(b) Write a shell script and associated launchd script which is set up as a LaunchAgent to run on a periodic basis. The shell script checks to see whether the target application is running, and if so, executes the caffeinate command above to keep the system from going idle while the target application is running.
Method (b) is tidier, as it doesn't have another visible support application running, doesn't require the user to change how they launch the target application, and allows for applications which get launched via methods such as opening a document.