sc3ctrl/sc3ctrl.m

72 lines
2.2 KiB
Mathematica
Raw Normal View History

2008-12-21 12:07:45 +00:00
#import <Foundation/Foundation.h>
#include "SC3Controller.h"
2008-12-21 12:07:45 +00:00
int main (int argc, const char **argv) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
SC3Controller *controller = [[SC3Controller alloc] init];
2008-12-21 12:07:45 +00:00
if(argv[1] == NULL) {
2008-12-21 21:33:49 +00:00
printf("Usage:\nEnsure SC3Controller.sc is in SC class load path. Then\n\nsc3ctrl -x (executes code in environment variable SC_INTERPRET_TEXT)\nsc3ctrl -x A_DIFFERENT_VARIABLE_NAME\n\nOther usages: see README\n");
2008-12-21 12:07:45 +00:00
} else {
NSString *arg = [NSString stringWithUTF8String:argv[1]];
if([arg isEqual:@"-x"]) {
2008-12-21 21:33:49 +00:00
[controller interpretContentsOfEnvironmentVariable:(argv[2] == NULL ? "SC_INTERPRET_TEXT" : argv[2])];
return 0;
}
if([arg isEqual:@"-d"]) {
if(argc < 3) {
2008-12-21 21:33:49 +00:00
printf("Usage: sc3ctrl -d classname\n");
} else {
[controller openHelpFile:[NSString stringWithUTF8String:argv[2]]];
}
}
if([arg isEqual:@"-j"]) {
if(argc < 3) {
2008-12-21 21:33:49 +00:00
printf("Usage: sc3ctrl -j classname\n");
2008-12-21 12:07:45 +00:00
} else {
[controller openClassFile:[NSString stringWithUTF8String:argv[2]]];
}
}
if([arg isEqual:@"-y"]) {
if(argc < 3) {
2008-12-21 21:33:49 +00:00
printf("Usage: sc3ctrl -y methodname\n");
} else {
[controller openImplementations:[NSString stringWithUTF8String:argv[2]]];
}
}
if([arg isEqual:@"-Y"]) {
if(argc < 3) {
2008-12-21 21:33:49 +00:00
printf("Usage: sc3ctrl -Y methodname\n");
} else {
[controller openReferences:[NSString stringWithUTF8String:argv[2]]];
2008-12-21 12:07:45 +00:00
}
2008-12-21 18:15:24 +00:00
}
if([arg isEqual:@"-s"]) {
[controller stop];
}
if([arg isEqual:@"-c"]) {
[controller clearPostWindow];
}
if([arg isEqual:@"-p"]) {
[controller postWindowToFront];
}
if([arg isEqual:@"-k"]) {
[controller recompile];
}
2008-12-21 12:07:45 +00:00
}
[controller close];
[controller release];
2008-12-21 12:07:45 +00:00
[pool drain];
return 0;
}