Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add command line support for template file to use.

Command line switch examples:
-template=template.html
-template=~/Project/template.html
-template=/Users/example/Project/template.html
  • Loading branch information...
commit 9aa12878a3f1480f23efbecded0e460ad8446a11 1 parent c949e4a
@clawoo authored
View
8 BetaBuilderAppDelegate.m
@@ -92,6 +92,7 @@ - (NSString *)defaultTemplatePath {
#define kIPAPathArgument @"-ipaPath"
#define kWebserverArgument @"-webserver"
#define kOutputDirectoryArgument @"-outputDirectory"
+#define kTemplateArgument @"-template"
- (void)processCommandLineArguments:(NSArray *)arguments {
NSLog(@"Processing Command Line Arguments");
@@ -99,6 +100,7 @@ - (void)processCommandLineArguments:(NSArray *)arguments {
NSString *ipaPath = nil;
NSString *webserverAddress = nil;
NSString *outputPath = nil;
+ NSString *templateFile = nil;
for (NSString *argument in arguments) {
NSArray *splitArgument = [argument componentsSeparatedByString:kArgumentSeperator];
@@ -110,11 +112,17 @@ - (void)processCommandLineArguments:(NSArray *)arguments {
webserverAddress = [splitArgument objectAtIndex:1];
} else if ([[splitArgument objectAtIndex:0] isEqualToString:kOutputDirectoryArgument]) {
outputPath = [splitArgument objectAtIndex:1];
+ } else if ([[splitArgument objectAtIndex:0] isEqualToString:kTemplateArgument]) {
+ templateFile = [splitArgument objectAtIndex:1];
}
}
}
if (ipaPath && webserverAddress && outputPath) {
+ if (templateFile)
+ {
+ self.builderController.templateFile = templateFile;
+ }
[self.builderController setupFromIPAFile:ipaPath];
[self.builderController generateFilesWithWebserverAddress:webserverAddress andOutputDirectory:outputPath];
[NSApp performSelector:@selector(terminate:) withObject:nil afterDelay:0.0];
View
1  BuilderController.h
@@ -44,6 +44,7 @@
@property (nonatomic) IBOutlet NSButton *openInFinderButton;
@property (nonatomic, copy) NSString *mobileProvisionFilePath;
@property (nonatomic, copy) NSString *appIconFilePath;
+@property (nonatomic, copy) NSString *templateFile;
@property (nonatomic, copy) NSURL *destinationPath;
@property (nonatomic, copy) NSString *previousDestinationPathAsString;
View
29 BuilderController.m
@@ -46,6 +46,7 @@ @implementation BuilderController
@synthesize openInFinderButton = _openInFinderButton;
@synthesize mobileProvisionFilePath = _mobileProvisionFilePath;
@synthesize appIconFilePath = _appIconFilePath;
+@synthesize templateFile = _templateFile;
@synthesize destinationPath = _destinationPath;
@synthesize previousDestinationPathAsString = _previousDestinationPathAsString;
@@ -192,7 +193,33 @@ - (void)generateFilesWithWebserverAddress:(NSString *)webserver andOutputDirecto
//create html file
NSString *applicationSupportPath = [[NSFileManager defaultManager] applicationSupportDirectory];
- NSString *templatePath = [applicationSupportPath stringByAppendingPathComponent:@"index_template.html"];
+ NSString *templatePath = nil;
+
+ if (_templateFile != nil)
+ {
+ if ([_templateFile hasPrefix:@"~"])
+ {
+ _templateFile = [_templateFile stringByExpandingTildeInPath];
+ }
+ if ([_templateFile hasPrefix:@"/"])
+ {
+ templatePath = _templateFile;
+ }
+ else
+ {
+ templatePath = [applicationSupportPath stringByAppendingPathComponent:_templateFile];
+ }
+ if (![[NSFileManager defaultManager] fileExistsAtPath:templatePath])
+ {
+ NSLog(@"Template file does not exist at path: %@", templatePath);
+ exit(1);
+ }
+ }
+ else
+ {
+ templatePath = [applicationSupportPath stringByAppendingPathComponent:@"index_template.html"];
+ }
+
NSString *htmlTemplateString = [NSString stringWithContentsOfFile:templatePath encoding:NSUTF8StringEncoding error:nil];
htmlTemplateString = [htmlTemplateString stringByReplacingOccurrencesOfString:@"[BETA_NAME]" withString:[self.bundleNameField stringValue]];
htmlTemplateString = [htmlTemplateString stringByReplacingOccurrencesOfString:@"[BETA_VERSION]" withString:[self.bundleVersionField stringValue]];
Please sign in to comment.
Something went wrong with that request. Please try again.