~/.ghb/presets has your GUI presets stored as a PropertyList (it is a kind of XML document). You can take the settings from here and translate them into command line arguments for the CLI. Sadly the CLI does not read the GUI's config file or any other config. If you can code in C(++), adding that support would probably not be too hard. The CLI lives in test/test.c in the Handbrake source tree.
Here is a quick and dirty bit of Python to get you started. Plist.py can be found here http://winappdbg.sourceforge.net/blog/PList.py:
#!/usr/bin/env python
import sys
import PList
def translate(item):
args = []
if "AudioList" in item:
args.append(("-E", item["AudioList"][0]["AudioEncoderActual"]))
return args
def invoke(args):
print "HandbrakeCLI " + " ".join(" ".join(arg) for arg in args)
presets = sys.argv[1]
name = sys.argv[2]
data = PList.fromstring(open(presets).read())
for item in data:
if isinstance(item, dict):
if 'PresetName' in item:
if item['PresetName'] == name:
invoke(translate(item))
Good luck and have fun.