title: Command Line Tool interact with Cocoa app
body: <p>I have a Cocoa Document-Based Application (text editor) and I want to be able to interact with it from the command line.</p>
  
  <p>For example, I'd like to set it as the editor for typing git/svn commit messages on the command line.</p>
  
  <p>Assuming I create a Command Line Tool using Foundation, what is the best way for my command line tool to communicate with the GUI application?</p>
  
  <p>Obviously I can use standard open events to have my app open a specific file, but I also need the command line app to wait until the GUI app has finished with the document (user closes the editor window) before exiting (similar to <code>mate -w file.txt</code> in TextMate's command line tool, or the equivalent in various other mac text editors).</p>
  
  <p>TextMate 2 <a href="https://github.com/textmate/textmate/blob/master/Applications/mate/src/mate.cc">uses a socket file</a>. Is this the best approach? If possible I'd like to use something higher level, perhaps <code>NSDistributedNotificationCenter</code>.</p>