title: MacOS app - why does CommandLine.arguments of an already open app not contain the passed --args arguments?
body: <p>I have a macOS app which most users use by drag and dropping images on the app icon or my menu bar icon. Some users also use my app through Terminal by running the following commands:</p>
  <pre><code>open -a /Users/username/Library/Developer/Xcode/DerivedData/AppName-bomyuotvsgqtachwwiidvpiaktgc/Build/Products/Debug/AppName.app /Users/username/Downloads/image.jpeg
  </code></pre>
  <p>My app handles the link/links being passed in the <code>func application(_ sender: NSApplication, openFiles filenames: [String])</code> method of AppDelegate.</p>
  <p>This works fine so far. If my app is already open, the <code>openFiles</code> still gets called by MacOS with the new image path and my app opens a new window to display it. This all works well.</p>
  <p>Now I want users to be able to pass certain arguments to my app. For example this:</p>
  <pre><code>open -a /Users/username/Library/Developer/Xcode/DerivedData/AppName-bomyuotvsgqtachwwiidvpiaktgc/Build/Products/Debug/AppName.app /Users/username/Downloads/image.jpeg --args full
  </code></pre>
  <p>Here I want to receive the <code>full</code> argument. I read on few other posts to use the <code>CommandLine.arguments</code> API. But this doesn't seem to contain the arguments. Each time the value of <code>CommandLine.arguments</code> equals to this:</p>
  <pre><code>[&quot;/Users/username/Library/Developer/Xcode/DerivedData/AppName-bomyuotvsgqtachwwiidvpiaktgc/Build/Products/Debug/AppName.app/Contents/MacOS/AppName&quot;, &quot;-NSDocumentRevisionsDebugMode&quot;, &quot;YES&quot;]
  </code></pre>
  <p>I think this is because the <code>CommandLine.arguments</code> only works when the app is initially launched and arguments are passed into the <code>main</code> function. But for an already opened app, these don't get passed as <code>main</code> isn't called again for an already running app.</p>
  <p>How do I achieve this?</p>