ObjFW  Check-in [227351155f]

Overview
Comment:of{http,zip}: Better documentation of long options
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 227351155f376fb77f3b4c38874e0425bc8619d4fe261f6e932110541ac206a9
User & Date: js on 2015-12-05 21:23:06
Other Links: manifest | tags
Context
2015-12-29
21:33
Refactor OFKernelEventObserver check-in: e9b4700cb6 user: js tags: trunk
2015-12-05
21:23
of{http,zip}: Better documentation of long options check-in: 227351155f user: js tags: trunk
21:03
OFOptionsParser: Fix *isSpecifiedPtr not being set check-in: aa89a3c059 user: js tags: trunk
Changes

Modified utils/ofhttp/OFHTTP.m from [545bac3fa9] to [4ffeaaca45].

74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91





















92
93
94
95
96
97
98
74
75
76
77
78
79
80











81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108







-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







{
	[of_stderr writeFormat:
	    @"Usage: %@ -[cehHmoOPqv] url1 [url2 ...]\n",
	    [OFApplication programName]];

	if (full)
		[stream writeString:
		    @"\nOptions:\n"
		    @"    -b  Specify the file to send as body\n"
		    @"    -c  Continue download of existing file\n"
		    @"    -h  Show this help\n"
		    @"    -H  Add a header (e.g. X-Foo:Bar)\n"
		    @"    -m  Set the method of the HTTP request\n"
		    @"    -o  Specify output file name\n"
		    @"    -O  Do a HEAD request to detect file name\n"
		    @"    -P  Specify SOCKS5 proxy\n"
		    @"    -q  Quiet mode (no output, except errors)\n"
		    @"    -v  Verbose mode (print headers)\n"];
		    @"\nOptions:\n    "
		    @"-b  --body           "
		    @"  Specify the file to send as body\n    "
		    @"-c  --continue       "
		    @"  Continue download of existing file\n    "
		    @"-h  --help           "
		    @"  Show this help\n    "
		    @"-H  --header         "
		    @"  Add a header (e.g. X-Foo:Bar)\n    "
		    @"-m  --method         "
		    @"  Set the method of the HTTP request\n    "
		    @"-o  --output         "
		    @"  Specify output file name\n    "
		    @"-O  --detect-filename"
		    @"  Do a HEAD request to detect the file name\n    "
		    @"-P  --proxy          "
		    @"  Specify SOCKS5 proxy\n    "
		    @"-q  --quiet          "
		    @"  Quiet mode (no output, except errors)\n    "
		    @"-v  --verbose        "
		    @"  Verbose mode (print headers)\n"];

	[OFApplication terminateWithStatus: status];
}

@implementation OFHTTP
- init
{
290
291
292
293
294
295
296
297
298


299
300
301
302
303
304
305



306
307
308
309
310
311
312
300
301
302
303
304
305
306


307
308
309
310
311
312
313


314
315
316
317
318
319
320
321
322
323







-
-
+
+





-
-
+
+
+







	_outputPath = [outputPath copy];
	_URLs = [[optionsParser remainingArguments] retain];

	if ([_URLs count] < 1)
		help(of_stderr, false, 1);

	if (_quiet && _verbose) {
		[of_stderr writeFormat: @"%@: -q and -v are mutually "
					@"exclusive!\n",
		[of_stderr writeFormat: @"%@: -q / --quiet and -v / --verbose "
					@"are mutually exclusive!\n",
					[OFApplication programName]];
		[OFApplication terminateWithStatus: 1];
	}

	if (_outputPath != nil && [_URLs count] > 1) {
		[of_stderr writeFormat: @"%@: Cannot use -o when more than "
					@"one URL has been specified!\n",
		[of_stderr writeFormat: @"%@: Cannot use -o / --output when "
					@"more than one URL has been "
					@"specified!\n",
					[OFApplication programName]];
		[OFApplication terminateWithStatus: 1];
	}

	[self performSelector: @selector(downloadNextURL)
		   afterDelay: 0];
}

Modified utils/ofzip/OFZIP.m from [d383d3b508] to [7e146b0671].

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
93
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
93
94
95
96







-
-
-
-
-
-
-
+
+
+
+
+
+
+
+





-
+
+

-
-
+
+
+







	[stream writeFormat:
	    @"Usage: %@ -[fhlnqvx] archive.zip [file1 file2 ...]\n",
	    [OFApplication programName]];

	if (full)
		[stream writeString:
		    @"\nOptions:\n"
		    @"    -f  Force / override files\n"
		    @"    -h  Show this help\n"
		    @"    -l  List all files in the archive\n"
		    @"    -n  Never override files\n"
		    @"    -q  Quiet mode (no output, except errors)\n"
		    @"    -v  Verbose output for file list\n"
		    @"    -x  Extract files\n"];
		    @"    -f  --force      Force / override files\n"
		    @"    -h  --help       Show this help\n"
		    @"    -l  --list       List all files in the archive\n"
		    @"    -n  --no-clober  Never override files\n"
		    @"    -q  --quiet      Quiet mode (no output, except "
		    @"errors)\n"
		    @"    -v  --verbose    Verbose output for file list\n"
		    @"    -x  --extract    Extract files\n"];

	[OFApplication terminateWithStatus: status];
}

static void
mutuallyExclusiveError(of_unichar_t option1, of_unichar_t option2)
mutuallyExclusiveError(of_unichar_t shortOption1, OFString *longOption1,
    of_unichar_t shortOption2, OFString *longOption2)
{
	[of_stderr writeFormat: @"Error: -%C and -%C are mutually exclusive!\n",
				option1, option2];
	[of_stderr writeFormat:
	    @"Error: -%C / --%@ and -%C / --%@ are mutually exclusive!\n",
	    shortOption1, longOption1, shortOption2, longOption2];
	[OFApplication terminateWithStatus: 1];
}

static void
setPermissions(OFString *path, OFZIPArchiveEntry *entry)
{
#ifdef OF_HAVE_CHMOD
124
125
126
127
128
129
130
131


132
133
134
135
136
137


138
139
140
141
142
143


144
145
146
147
148
149


150
151
152
153
154
155
156


157
158
159
160
161
162
163
127
128
129
130
131
132
133

134
135
136
137
138
139
140

141
142
143
144
145
146
147

148
149
150
151
152
153
154

155
156
157
158
159
160
161
162

163
164
165
166
167
168
169
170
171







-
+
+





-
+
+





-
+
+





-
+
+






-
+
+







	OFArray OF_GENERIC(OFString*) *remainingArguments, *files;
	OFZIPArchive *archive;

	while ((option = [optionsParser nextOption]) != '\0') {
		switch (option) {
		case 'f':
			if (_override < 0)
				mutuallyExclusiveError('f', 'n');
				mutuallyExclusiveError(
				    'f', @"force", 'n', @"no-clobber");

			_override = 1;
			break;
		case 'n':
			if (_override > 0)
				mutuallyExclusiveError('f', 'n');
				mutuallyExclusiveError(
				    'f', @"force", 'n', @"no-clobber");

			_override = -1;
			break;
		case 'v':
			if (_outputLevel < 0)
				mutuallyExclusiveError('v', 'q');
				mutuallyExclusiveError(
				    'q', @"quiet", 'v', @"verbose");

			_outputLevel++;
			break;
		case 'q':
			if (_outputLevel > 0)
				mutuallyExclusiveError('v', 'q');
				mutuallyExclusiveError(
				    'q', @"quiet", 'v', @"verbose");

			_outputLevel--;
			break;
		case 'l':
		case 'x':
			if (mode != '\0')
				mutuallyExclusiveError('x', 'l');
				mutuallyExclusiveError(
				    'l', @"list", 'x', @"extract");

			mode = option;
			break;
		case 'h':
			help(of_stdout, true, 0);
			break;
		case '=':