On 20/10/2009, at 10:58 PM, XiaoGang Li wrote:

Greetings,
I have created an document-based cocoa application, now I need to
provide a command line interface for my users.
for example, users input this into the terminal:
./myApplication.app/Contents/MacOS/myApplication -c --srcFolder "A/B/C"
--dstFolder "A/B/D";
I can get the argument information through [[NSProcessInfo processInfo]
arguments] in the init method of the application
delegate, and parse the arguments, then step by step.
My question is that, I don't want the window and other document be displayed
on the screen, even the menu.
I want all the action be processed  without user's interventio.
Maybe, this feature seems odd. anyway, however, user can open my application
in the Finder, and open a document to edit it. but they
also can run it like a shell command utility to do some other faceless work,
like convert the type the document to another type.

I don't know whether I have a detailed description for my issue, but I will
be very appreciated for your feedback.

Your app has to detect whether it's been started from the finder or whether it's being called from the command line. I'm not sure off the top of my head
how best to do this, but it shouldn't be too hard to figure out a way.
Then it'll either show or not show your UI, as appropriate. Simple.

There's multiple ways to structure this though. You could have 2 separate apps, but built with as much common code as possible; you could have a single app which shows or doesnt show the UI - as described above; you could even have a 3rd app which does the heavy lifting, but is called by either a command line
tool or by a regular cocoa based app.
Without knowing what exactly you're trying to do, it's hard to comment on the
best aproach.

By the way, an alternative aproach to calling into your application bundle from the command line is to simply type 'open -a myApplication', however I
dont think this will allow you to pass args as you've described above.


paulm

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to