MCPcopy Create free account
hub / github.com/apitrace/apitrace / command

Function command

cli/cli_repack.cpp:225–278  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

223}
224
225static int
226command(int argc, char *argv[])
227{
228 Format format = FORMAT_SNAPPY;
229 int opt;
230 int quality = 0;
231 while ((opt = getopt_long(argc, argv, shortOptions, longOptions, NULL)) != -1) {
232 switch (opt) {
233 case 'h':
234 usage();
235 return 0;
236 case 'b':
237 format = FORMAT_BROTLI;
238 quality = BROTLI_DEFAULT_QUALITY;
239 if (optarg) {
240 quality = atoi(optarg);
241 if (quality < BROTLI_MIN_QUALITY || quality > BROTLI_MAX_QUALITY) {
242 std::cerr << "error: brotli quality must be between " << BROTLI_MIN_QUALITY << " and " << BROTLI_MAX_QUALITY << std::endl;
243 return 1;
244 }
245 }
246 break;
247 case 's':
248 format = FORMAT_SNAPPY;
249 break;
250 case 'z':
251 format = FORMAT_ZSTD;
252 quality = 3;
253 if (optarg) {
254 quality = atoi(optarg);
255 if (quality < 1 || quality > 22) {
256 std::cerr << "error: zstd quality must be between 1 and 22" << std::endl;
257 return 1;
258 }
259 }
260 break;
261 case 'g':
262 format = FORMAT_ZLIB;
263 break;
264 default:
265 std::cerr << "error: unexpected option `" << (char)opt << "`\n";
266 usage();
267 return 1;
268 }
269 }
270
271 if (argc != optind + 2) {
272 std::cerr << "error: insufficient number of arguments\n";
273 usage();
274 return 1;
275 }
276
277 return repack(argv[optind], argv[optind + 1], format, quality);
278}
279
280const Command repack_command = {
281 "repack",

Callers

nothing calls this directly

Calls 2

repackFunction · 0.85
usageFunction · 0.70

Tested by

no test coverage detected