CLI: allow passing of command line arguments

This commit is contained in:
Pieter de Bie
2008-08-28 16:24:45 +02:00
parent 2702572a7b
commit 5ceb62a0d5
3 changed files with 11 additions and 4 deletions
+1 -1
View File
@@ -20,5 +20,5 @@
#define PBCLIProxyErrorDomain @"PBCLIProxyErrorDomain"
@protocol GitXCliToolProtocol
- (BOOL)openRepository:(NSURL*)repositoryPath error:(NSError**)error;
- (BOOL)openRepository:(NSURL*)repositoryPath arguments: (NSArray*) args error:(NSError**)error;
@end
+1 -1
View File
@@ -25,7 +25,7 @@
return self;
}
- (BOOL)openRepository:(NSURL*)repositoryPath error:(NSError**)error;
- (BOOL)openRepository:(NSURL*)repositoryPath arguments: (NSArray*) args error:(NSError**)error;
{
// FIXME I found that creating this redundant NSURL reference was necessary to
// work around an apparent bug with GC and Distributed Objects
+9 -2
View File
@@ -16,7 +16,7 @@ NSDistantObject* connect()
}
int main(int argc, const char* argv)
int main(int argc, const char** argv)
{
// Attempt to connect to the app
id proxy = connect();
@@ -38,9 +38,16 @@ int main(int argc, const char* argv)
}
if ([[[NSProcessInfo processInfo] environment] objectForKey:@"PWD"]) {
int i;
argv++; argc--;
NSURL* url = [NSURL fileURLWithPath:[[[NSProcessInfo processInfo] environment] objectForKey:@"PWD"]];
NSMutableArray* arguments = [NSMutableArray arrayWithCapacity:argc];
for (i = 0; i < argc; i++)
[arguments addObject: [NSString stringWithCString:argv[i]]];
NSError* error = nil;
if (![proxy openRepository:url error:&error]) {
if (![proxy openRepository:url arguments: arguments error:&error]) {
fprintf(stderr, "Error opening repository at %s", [[url path] UTF8String]);
if (error) {
fprintf(stderr, ": %s", [[error localizedFailureReason] UTF8String]);