From 5ceb62a0d51ff9473cb41d19a272ac3d8940b822 Mon Sep 17 00:00:00 2001 From: Pieter de Bie Date: Thu, 28 Aug 2008 16:24:45 +0200 Subject: [PATCH] CLI: allow passing of command line arguments --- PBCLIProxy.h | 2 +- PBCLIProxy.mm | 2 +- gitx.mm | 11 +++++++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/PBCLIProxy.h b/PBCLIProxy.h index 8f6e1b7..2dcd639 100644 --- a/PBCLIProxy.h +++ b/PBCLIProxy.h @@ -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 \ No newline at end of file diff --git a/PBCLIProxy.mm b/PBCLIProxy.mm index 12e919b..aed7967 100644 --- a/PBCLIProxy.mm +++ b/PBCLIProxy.mm @@ -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 diff --git a/gitx.mm b/gitx.mm index 16483c1..2797b04 100644 --- a/gitx.mm +++ b/gitx.mm @@ -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]);