From: Scott T. <ea...@ma...> - 2008-04-20 19:22:48
|
On Apr 20, 2008, at 1:57 PM, Rupert BARROW wrote: > Scott, > My problem is more related to RubyCocoa : > > I have a RubyCocoa app called MyApp.app. > I would like to be able to call this from the command-line with my > own command-line argument, e.g. > MyApp.app/Contents/MacOS/MyApp --myswitch > > When I do this, I get an error reported by ruby not recognising this > switch. > > How can I get pass the Ruby parser, so that I can later (in my app) > use the ARGV global to recognize which switch was passed to my app ? > I need something like the "-s", but this only works if I tell it to > load a ruby file; I just want it to find rb_main.rb and run away I think I understand. RBApplicationMain will parse the command line arguments as if they were arguments to the Ruby interpreter. If you wish to avoid this, you can use RBApplicationInit instead, and take responsibility for calling NSApplicationMain youself. In other words, change your main routine to: int main(int argc, const char *argv[]) { RBApplicationInit("rb_main.rb", argc, argv, nil); return NSApplicationMain(argc,argv); } This should invoke rb_main (without parsing the arguments as Ruby arguments) and then begin the application as normal. Scott |