forked from HunterHillegas/iOS-BetaBuilder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.m
92 lines (78 loc) · 2.26 KB
/
main.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
//
// main.m
// BetaBuilder
//
// Created by Hunter Hillegas on 8/7/10.
// Copyright 2010 Hunter Hillegas. All rights reserved.
//
#import <Cocoa/Cocoa.h>
#import <unistd.h>
#import <stdio.h>
#import "BuilderController.h"
static int usage(char *name) {
fprintf(stderr, "Usage: %s [options]\n", name);
fprintf(stderr, "If no options are specified, the app runs in interactive mode.\n\
\n\
-h This message\n\
-i <file> The input file (.zip or .ipa) (required)\n\
-o <dir> The output directory (required)\n\
-u <url> The URL of the output directory (required)\n\
-r <file> The README.txt file to include (optional)\n\
\n");
return(1);
}
int main(int argc, char *argv[])
{
int ch;
BOOL optBatch = NO;
NSString *optInputFile = nil;
NSString *optOutputDirectory = nil;
NSString *optReadmePath = nil;
NSString *optUrl = nil;
// Do we have options?
while((ch = getopt(argc, argv, "hi:o:r:u:")) != -1) {
switch(ch) {
case 'i':
optBatch = YES;
if(optInputFile != nil) [optInputFile release];
optInputFile = [NSString stringWithCString:optarg encoding:NSASCIIStringEncoding];
break;
case 'o':
optBatch = YES;
if(optOutputDirectory != nil) [optOutputDirectory release];
optOutputDirectory = [NSString stringWithCString:optarg encoding:NSASCIIStringEncoding];
break;
case 'r':
optBatch = YES;
if(optReadmePath != nil) [optReadmePath release];
optReadmePath = [NSString stringWithCString:optarg encoding:NSASCIIStringEncoding];
break;
case 'u':
optBatch = YES;
if(optUrl != nil) [optUrl release];
optUrl = [NSString stringWithCString:optarg encoding:NSASCIIStringEncoding];
break;
case 'h':
case '?':
default:
return usage(argv[0]);
break;
}
}
if(!optBatch) {
// Interactive gui loop
return NSApplicationMain(argc, (const char **) argv);
}
if(optInputFile == nil || optOutputDirectory == nil || optUrl == nil) {
return usage(argv[0]);
}
BuilderController *bc = [[BuilderController alloc] initInBatchMode];
// Drive the controller...
bc.saveDirectory = optOutputDirectory;
bc.readmePath = optReadmePath;
bc.webserverDirectoryField.stringValue = optUrl;
if(![bc setupFromIPAFile:optInputFile]) {
exit(1);
}
[bc generateFiles:nil];
}