Permalink
Browse files

Don't hardcode the path to the GitNub application in the nub CLI tool.

I didn't want to install GitNub in /Applications, which caused the nub
command to fail terribly.  This change uses the standard cocoa
NSWorkspace API for opening applications with paths.

Note that this changes causes a slightly different, but more
``normal'' behavior for applications.

If it is desirable to have multiple repos open at the same time, that
should be handled in the application itself.  This invocation via nub
should already do the right thing to accommodate that.
  • Loading branch information...
dustin committed Mar 12, 2008
1 parent dbe1954 commit c9db2c13ce5beff291191d14a6130072560a5fc0
Showing with 14 additions and 8 deletions.
  1. +10 −8 nub/nub.m
  2. +4 −0 nub/nub.xcodeproj/project.pbxproj
View
@@ -1,15 +1,17 @@
-#import <Foundation/Foundation.h>
+#import <Cocoa/Cocoa.h>
int main (int argc, const char * argv[]) {
+ char buf[PATH_MAX];
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
-
+
// NSArray *myArgs = [[NSProcessInfo processInfo] arguments];
- // NSLog(@"%@", myArgs);
-
- NSTask *task = [[NSTask alloc] init];
- [task setLaunchPath:@"/Applications/GitNub.app/Contents/MacOS/GitNub"];
- [task launch];
-
+ // NSLog(@"%@", myArgs);
+
+ NSString *path=[[NSString alloc] initWithCString:getcwd(buf, sizeof(buf))];
+
+ [[NSWorkspace sharedWorkspace] openFile:path withApplication:@"GitNub"];
+
+ [path release];
[pool drain];
return 0;
}
@@ -10,6 +10,7 @@
8DD76F9A0486AA7600D96B5E /* nub.m in Sources */ = {isa = PBXBuildFile; fileRef = 08FB7796FE84155DC02AAC07 /* nub.m */; settings = {ATTRIBUTES = (); }; };
8DD76F9C0486AA7600D96B5E /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 08FB779EFE84155DC02AAC07 /* Foundation.framework */; };
8DD76F9F0486AA7600D96B5E /* nub.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6859EA3029092ED04C91782 /* nub.1 */; };
+ DA2B05160D8897590018BF34 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA2B05150D8897590018BF34 /* Cocoa.framework */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
@@ -31,6 +32,7 @@
32A70AAB03705E1F00C91783 /* nub_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = nub_Prefix.pch; sourceTree = "<group>"; };
8DD76FA10486AA7600D96B5E /* nub */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = nub; sourceTree = BUILT_PRODUCTS_DIR; };
C6859EA3029092ED04C91782 /* nub.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = nub.1; sourceTree = "<group>"; };
+ DA2B05150D8897590018BF34 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -39,6 +41,7 @@
buildActionMask = 2147483647;
files = (
8DD76F9C0486AA7600D96B5E /* Foundation.framework in Frameworks */,
+ DA2B05160D8897590018BF34 /* Cocoa.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -68,6 +71,7 @@
08FB779DFE84155DC02AAC07 /* External Frameworks and Libraries */ = {
isa = PBXGroup;
children = (
+ DA2B05150D8897590018BF34 /* Cocoa.framework */,
08FB779EFE84155DC02AAC07 /* Foundation.framework */,
);
name = "External Frameworks and Libraries";

0 comments on commit c9db2c1

Please sign in to comment.