Charles supports a few command line options out of the box, documented here.
Unfortunately they seem to operate only as parameters for new Charles sessions, so you won't be able to run commands on a running instance of Charles.
Start a specific Charles session
A Charles session contains all of your recorded information. It is represented by the Session window; by default a new session is automatically created when you start Charles.
Sessions can be saved from File → Save Session (⌘+S).
Once saved, if you want you can start Charles from the saved session by running:
/Applications/Charles.app/Contents/MacOS/Charles YOUR_SAVED_SESSION_PATH
Start Charles with a specific configuration
This part is not well documented, so I had to dig a bit in the settings to understand how it works.
By default Charles stores its configuration in /Users/YOUR_USER/Library/Preferences/com.xk72.Charles.config
, a readable xml file that contains all the Charles settings.
If needed, you can copy this file to another location, tweak the settings your interested into and start Charles directly from it:
/Applications/Charles.app/Contents/MacOS/Charles -config YOUR_CONFIG_PATH
Please notice that you can manually edit the configuration file only if Charles it not running.
Start Charles with throttling enabled
Easy peasy:
/Applications/Charles.app/Contents/MacOS/Charles -throttling
Start Charles in headless mode
You can run Charles in headless mode, so that no UI will be presented, but it will still proxy content.
/Applications/Charles.app/Contents/MacOS/Charles -headless
How can you control Charles in headless mode? You can use its Web Interface.
Thanks for the write up! Wanted to add a quick comment:
To get the ip address of your mac, you can try either:
ipconfig getifaddr en0
oripconfig getifaddr en1
in your terminal.