• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Adding commandline batch mode to Cocoa app
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Adding commandline batch mode to Cocoa app


  • Subject: Re: Adding commandline batch mode to Cocoa app
  • From: "Tom Harrington" <email@hidden>
  • Date: Sat, 22 Mar 2008 16:36:40 -0600

On Sat, Mar 22, 2008 at 4:26 PM, Carsten <email@hidden> wrote:
>  However, image processing apps can benefit from batch modes, and
>  although some things can be nicely handled by an in-app batch manager,
>  the ideal would be to also allow the application to be run from the
>  commandline, as a traditional unix utility.
>
>  Given the .app bundle format of Cocoa apps, I don't quite see how I
>  would do this. In main(), I have added an if contingent on the
>  existence of commandline parameters (which can be refined in case Mac
>  OS X uses these to launch drag-n-drop scenarios, something which I
>  don't know yet), which doesn't load the GUI in case the app has been
>  launched in commandline batch mode, but the executable is deep inside
>  the .app bundle...
>
>  What is the traditional Mac OS X/Cocoa way of handling such a
>  scenario, or is it simply not do it like this, and to force the user
>  to use an in-app batch manager?

You could just use the executable in the .app bundle, though it would
lead to some very long command lines.  For example you can run
TextEdit with "/Applications/TextEdit.app/Contents/MacOS/TextEdit".

One approach that some apps take is to have a separate command-line
tool which could be installed in /usr/local/bin or some other more
normal-seeming place.  With this approach you'd probably have a
regular drag-install app bundle with a menu item to optionally install
the command-line tool.  Depending on your architecture the
command-line tool could be as simple as a symbolic link to the main
bundle's binary.

Depending on your requirements, you might consider whether the
batch-mode processing would be better implemented as an Automator
action.

--
Tom Harrington
email@hidden
AIM: atomicbird1
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Adding commandline batch mode to Cocoa app
      • From: Carsten <email@hidden>
References: 
 >Adding commandline batch mode to Cocoa app (From: Carsten <email@hidden>)

  • Prev by Date: Adding commandline batch mode to Cocoa app
  • Next by Date: Re: Adding commandline batch mode to Cocoa app
  • Previous by thread: Adding commandline batch mode to Cocoa app
  • Next by thread: Re: Adding commandline batch mode to Cocoa app
  • Index(es):
    • Date
    • Thread